C casey Registered User. Local time Today, 12:16 Joined Dec 5, 2000 Messages 448 Jan 19, 2001 #1 I'm unfamiliar with the process of creating and running SQL statements through VB code. Can anyone tell me the proper way to do this? Trying to figure this out on my own has my head spinning.
I'm unfamiliar with the process of creating and running SQL statements through VB code. Can anyone tell me the proper way to do this? Trying to figure this out on my own has my head spinning.
B BarkerD Registered User. Local time Today, 12:16 Joined Dec 1, 1999 Messages 106 Jan 19, 2001 #2 Write the SQL code as you normally would. Assign the SQL statement to a string variable, and use this variable when needed. eg: strSQL="SELECT * FROM Table WHERE [Field] = Criteria ;" If you want to use variables in criteria, use string concatenation. Dim strVariable as String Dim lngVariable as long strSQL="SELECT * FROM Table WHERE [Field] = """ & strVariable & """ And [Field2] = " & lngVariable & ";" Hope this is what you were looking for. Duane Barker
Write the SQL code as you normally would. Assign the SQL statement to a string variable, and use this variable when needed. eg: strSQL="SELECT * FROM Table WHERE [Field] = Criteria ;" If you want to use variables in criteria, use string concatenation. Dim strVariable as String Dim lngVariable as long strSQL="SELECT * FROM Table WHERE [Field] = """ & strVariable & """ And [Field2] = " & lngVariable & ";" Hope this is what you were looking for. Duane Barker
C casey Registered User. Local time Today, 12:16 Joined Dec 5, 2000 Messages 448 Jan 19, 2001 #3 Question: Can this method be used to run action queries that update or insert information into my tables or do I have to use another method?
Question: Can this method be used to run action queries that update or insert information into my tables or do I have to use another method?
T tc3of4 Registered User. Local time Today, 12:16 Joined Jan 18, 2001 Messages 32 Jan 20, 2001 #4 In continuation to BarkerD's response, just in case you didn't know how to run the SQL you must type DoCmd.RunSQL strSQL To your second question, you can run any -VALID- SQL statement, including Update and Make Tables etc... tc3of4
In continuation to BarkerD's response, just in case you didn't know how to run the SQL you must type DoCmd.RunSQL strSQL To your second question, you can run any -VALID- SQL statement, including Update and Make Tables etc... tc3of4
C casey Registered User. Local time Today, 12:16 Joined Dec 5, 2000 Messages 448 Jan 21, 2001 #5 Thanks for the help. That really makes it a lot easier for me.