If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Passing Date from a form to SQL Select
I'm having problem passing dates from a from in to my query so I can load a recorset in a another form. I"m getting runtime error 2001. GCriteria = "[JobName] Like """ & Forms![frmSearchByJobandDate]![txtSearchString] & "*" & _ """ AND [JobDate] = """ & Forms![frmSearchByJobandDate]![CboBeginningDate] & "*" & _ """ AND [JobDate] = """ & Forms![frmSearchByJobandDate]![CboEndingDate] & "*" & """" Form_frm_LogJobDataView.RecordSource = "select * from tbl_JobData where " & GCriteria I'm sure my syntax is very bad but I can't figure it out. Any help would be greatly appreciated, Thanks Little Penny |
#2
|
|||
|
|||
Passing Date from a form to SQL Select
On Fri, 15 Jan 2010 19:53:33 -0500, Little Penny
wrote: Dates need to be wrapped by #-signs, assuming your back-end is Access. -Tom. Microsoft Access MVP I'm having problem passing dates from a from in to my query so I can load a recorset in a another form. I"m getting runtime error 2001. GCriteria = "[JobName] Like """ & Forms![frmSearchByJobandDate]![txtSearchString] & "*" & _ """ AND [JobDate] = """ & Forms![frmSearchByJobandDate]![CboBeginningDate] & "*" & _ """ AND [JobDate] = """ & Forms![frmSearchByJobandDate]![CboEndingDate] & "*" & """" Form_frm_LogJobDataView.RecordSource = "select * from tbl_JobData where " & GCriteria I'm sure my syntax is very bad but I can't figure it out. Any help would be greatly appreciated, Thanks Little Penny |
#3
|
|||
|
|||
Passing Date from a form to SQL Select
My brain is fried on this. Any other assistance would be greatly appreiciated. GCriteria = "[JobName] Like """ & _ Forms![frmSearchByJobandDate]![txtSearchString] & "*" & _ """ AND [JobDate] = """ & "#" & Forms![frmSearchByJobandDate]![CboBeginningDate] & "#" & _ """ AND [JobDate] = """ & "#" & Forms![frmSearchByJobandDate]![CboEndingDate] & "#" & """" On Fri, 15 Jan 2010 19:04:29 -0700, Tom van Stiphout wrote: On Fri, 15 Jan 2010 19:53:33 -0500, Little Penny wrote: Dates need to be wrapped by #-signs, assuming your back-end is Access. -Tom. Microsoft Access MVP I'm having problem passing dates from a from in to my query so I can load a recorset in a another form. I"m getting runtime error 2001. GCriteria = "[JobName] Like """ & Forms![frmSearchByJobandDate]![txtSearchString] & "*" & _ """ AND [JobDate] = """ & Forms![frmSearchByJobandDate]![CboBeginningDate] & "*" & _ """ AND [JobDate] = """ & Forms![frmSearchByJobandDate]![CboEndingDate] & "*" & """" Form_frm_LogJobDataView.RecordSource = "select * from tbl_JobData where " & GCriteria I'm sure my syntax is very bad but I can't figure it out. Any help would be greatly appreciated, Thanks Little Penny |
#4
|
|||
|
|||
Passing Date from a form to SQL Select
You must be sure how you format the dates. Try this link:
http://www.techonthenet.com/access/f...ate/format.php Appearance of dates depend on local Access formatting and control panel settings (Regional settings etc). If you pass a date format that your code (query) cannot understand you will have trouble. If you change the date formatting on your pc in control panel you may also run into trouble (code that worked before stop working). Personally I have often created a function that translates any access date-field into a format my code understands. I use the vba functions Year(), , Month(), Day() to extract date information and put this together in a string where I am in full control. I guess you can do the same by using the # as described in the link above. Tore |
Thread Tools | |
Display Modes | |
|
|