A Microsoft Office (Excel, Word) forum. OfficeFrustration

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.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Passing Date from a form to SQL Select



 
 
Thread Tools Display Modes
  #1  
Old January 16th, 2010, 12:53 AM posted to microsoft.public.access.forms
Little Penny[_3_]
external usenet poster
 
Posts: 21
Default 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  
Old January 16th, 2010, 02:04 AM posted to microsoft.public.access.forms
Tom van Stiphout[_2_]
external usenet poster
 
Posts: 1,653
Default 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  
Old January 16th, 2010, 03:38 AM posted to microsoft.public.access.forms
Little Penny[_3_]
external usenet poster
 
Posts: 21
Default 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  
Old January 16th, 2010, 09:56 AM posted to microsoft.public.access.forms
Tore
external usenet poster
 
Posts: 12
Default 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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 11:15 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.