Click here to Skip to main content
14,391,319 members
Rate this:
Please Sign up or sign in to vote.
See more:
Am new to coding and would be grateful if you guys can help me to solve this issue to trying to search between two dates ie "From Date" to "To Date" and display the results in Grid View.

What I have tried:

I am currently using this code
Me.GBCPVRBindingSource.Filter = "RECORDING DATE >= "’ & DateTimePicker1.Text & "’ and RECORDING DATE <= "’ & DateTimePicker2.Text & "’". But the error i get shows this - "missing operand after 'Date' operator.

Can someone please help me with this code and get it right.
Thanks
Posted
Updated 8-Feb-17 6:15am

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

I notice there is white space in the column name of
RECORDING DATE
, wrap them in square brackets like this:
[RECORDING DATE]
.
Next, is the single quote for your datetimepickers, they are not nested correctly,
"’ & DateTimePicker1.Text & "’ 
it should be
'" & DateTimePicker1.Text & "’
same for datetimepicker2
Lastly, instead of
DateTimePicker1.Text
it should be more appropriately
DateTimePicker1.Value.ToString()
Learn DateTimePicker.Value Property[^] vs DateTimePicker.Text Property[^]
   
v3
Comments
Kobby Adom 8-Feb-17 11:52am
   
wow. that was really faster Peter. Thanks a lot. Its working well now. Am most grateful
Peter Leow 8-Feb-17 11:57am
   
You are welcome.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100