Re: Append Query help
- From: "Douglas J. Steele" <NOSPAM_djsteele@xxxxxxxxxxxxxxxxx>
- Date: Tue, 21 Aug 2007 12:31:12 -0400
Assuming that, say, submit_type is a text field, rather than
"," & Me![CboSubmittype] & ","
you'd use
",'" & Me![CboSubmittype] & "',"
Exagerated for clarity, that's
", ' " & Me![CboSubmittype] & " ' ,"
That'll work unless the value to be stored contains an apostrophe. In that
case, you need either
",""" & Me![CboSubmittype] & ""","
or
",'" & Replace(Me![CboSubmittype], "'", "''") & "',"
(Again, for clarity, that Replace function call is
Replace(Me![CboSubmittype], " ' ", " ' ' "))
Note that transfer_date is a date field, you need to delimit the value with
#, and you need to ensure that it's in a format that Access will correctly
interpret. Since you have no control over what date format your users may
have chosen in their Regional Settings, and since Access doesn't respect
many of the Regional Settings choices, you're best off using
"," & Format(Me![txtTransDate], \#yyyy\-mm\-dd\#") & ","
if txtTransDate contains a date only, or
"," & Format(Me![txtTransDate], \#yyyy\-mm\-dd hh\:nn\:ss\#") & ","
if it contains both a date and time.
--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)
"cableguy47905 via AccessMonster.com" <u4349@uwe> wrote in message
news:7708361696068@xxxxxx
Thank you both very much for your quick replies. I am having trouble
adding
the single quotes to the string. Each time I do, it thinks that the rest
of
the string is just comments. How do I add the single quotes to the VBA
string?
This is what I currently have that creates the string below:
stMapSQL = "INSERT INTO TBL_Map (MapID, submit_type, Push_to_Mainframe,
file_format, fields_ignore, logic, map_status, Business_Need, PPED_map,
Comments_map, transfer_date, test_file, revision_change) VALUES (" & Me!
[txtMapID] & "," & Me![CboSubmittype] & "," & Me![txtPushToMF] & "," & Me!
[txtFileFormat] & "," & Me![txtfields_ignore] & "," & Me![TxtLogic] & ","
&
Me![CboMapStatus] & "," & Me![CboBusinessNeed] & "," & Me![chkPPED] & ","
&
Me![TxtComments] & "," & Me![txtTransDate] & "," & Me![TxtTestFile] & ","
&
Me![txtRevision] & ");"
Thanks again,
Lee
Jana wrote:
I am trying to do an append query on the fly. I have several different[quoted text clipped - 22 lines]
types
of textboxes, check boxes, and combo boxes as input. The ones that I
seem to
--
Message posted via
AccessMonster.comhttp://www.accessmonster.com/Uwe/Forums.aspx/access-formscoding/200708/1
Lee:
If you need to insert the text 'New Request' into the map_status field
of the TBL_Map, then you need to wrap it with single quotes. Same
thing goes for Technology Issue.
So, you should change it as follows:
INSERT INTO TBL_Map (MapID, submit_type, Push_to_Mainframe,
file_format,
fields_ignore, logic, map_status, Business_Need, PPED_map,
Comments_map,
transfer_date, test_file, revision_change) VALUES (NewMap,FTP,H244ftp,
delimited,none,none,'New Request','Technology
Issue',-1,none,,none,none);
We might be better able to help you if you post the entire code that
is building your SQL string, since it is not clear where you're
getting the values from.
HTH,
Jana
--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/Forums.aspx/access-formscoding/200708/1
.
- Follow-Ups:
- Re: Append Query help
- From: cableguy47905 via AccessMonster.com
- Re: Append Query help
- References:
- Append Query help
- From: cableguy47905 via AccessMonster.com
- Re: Append Query help
- From: Jana
- Re: Append Query help
- From: cableguy47905 via AccessMonster.com
- Append Query help
- Prev by Date: Collection object fails within class
- Next by Date: Re: Append Query help
- Previous by thread: Re: Append Query help
- Next by thread: Re: Append Query help
- Index(es):
Relevant Pages
|