David Ball
Registered User.
- Local time
- Today, 16:03
- Joined
- Aug 9, 2010
- Messages
- 230
Hi,
I have this segment of code that adds data to fields FName and FPath in the table “Files”. It works fine but the syntax is a nightmare with all the double quotes and “and” symbols. I don’t really understand it.
I have another field in the table Files called CompletedBy that shows who updated the table (they type their name into a textbox “Text1” before clicking a command button to run the code). I would like to add this data to the table during the execution of strSQL. All the records added to the table Files will have that value in the CompletedBy field (say, Bob Jones).
I tried the below changes but the code doesn’t work. Not sure if it is the confusing syntax causing me problems or I’m just going about it the wrong way?
How would I add a value in field CompletedBy, from the textbox Text1, to all records added to table Files when the code is run?
Thanks very much
Dave
I have this segment of code that adds data to fields FName and FPath in the table “Files”. It works fine but the syntax is a nightmare with all the double quotes and “and” symbols. I don’t really understand it.
Code:
[FONT=Calibri][SIZE=3]strSQL = "INSERT INTO Files " _[/SIZE][/FONT]
[SIZE=3][FONT=Calibri] & " (FName, FPath) " _[/FONT][/SIZE]
[SIZE=3][FONT=Calibri] & " SELECT """ & strTemp & """" _[/FONT][/SIZE]
[SIZE=3][FONT=Calibri] & ", """ & strFolder & """;"[/FONT][/SIZE]
[SIZE=3][FONT=Calibri] CurrentDb.Execute strSQL[/FONT][/SIZE]
I have another field in the table Files called CompletedBy that shows who updated the table (they type their name into a textbox “Text1” before clicking a command button to run the code). I would like to add this data to the table during the execution of strSQL. All the records added to the table Files will have that value in the CompletedBy field (say, Bob Jones).
I tried the below changes but the code doesn’t work. Not sure if it is the confusing syntax causing me problems or I’m just going about it the wrong way?
Code:
[FONT=Calibri][SIZE=3]strSQL = "INSERT INTO Files " _[/SIZE][/FONT]
[SIZE=3][FONT=Calibri] & " (FName, FPath, [B]CompletedBy[/B]) " _[/FONT][/SIZE]
[SIZE=3][FONT=Calibri] & " SELECT """ & strTemp & """" _[/FONT][/SIZE]
[SIZE=3][FONT=Calibri] & ", """ & strFolder & """ [B]& Me.Text1 &[/B] """;"[/FONT][/SIZE]
[SIZE=3][FONT=Calibri] CurrentDb.Execute strSQL[/FONT][/SIZE]
How would I add a value in field CompletedBy, from the textbox Text1, to all records added to table Files when the code is run?
Thanks very much
Dave