Okay...wasn't sure if about some of your commands and whether they were custom names or stuff Access uses directly? Thanks for the clarification. Dian D. Chapman Technical Consultant, Microsoft MVP & Instructor Free Tutorials: www.mousetrax.com/techtrax Free Word Tips & Tricks eBook: www.mousetrax.com/books.html Learn VBA the easy way, thru video! www.mousetrax.com/techcourses.html -----Original Message----- From: mso-bounce@xxxxxxxxxxxxx [mailto:mso-bounce@xxxxxxxxxxxxx] On Behalf Of James LaBorde Sent: Wednesday, October 15, 2003 10:21 AM To: 'mso@xxxxxxxxxxxxx' Subject: [mso] Re: Access VBA SQL :VSMail mx2 Dian, You are still doing the same thing. I just use a couple of strings to avoid having to retype the SQL since some of the searches can get a bit longer. It is still essentially the same thing. :o) James -----Original Message----- From: Dian Chapman [mailto:dian@xxxxxxxxxxxxx] Sent: Tuesday, October 14, 2003 9:24 PM To: mso@xxxxxxxxxxxxx Subject: [mso] Re: Access VBA SQL :VSMail mx2 >The only reason for all the parts is so that he can loop through and >reuse the same sql with a different where clause each time. Sure, I know how to build variable statements, I just do it a bit different and use different terms with ADO. Here's a recent SIMPLE sample.... Function funcGetPatientQueryString _ (strSearchBy As String, varOne As Variant, Optional varTwo As Variant) On Error GoTo Handler 'decipher query string to use Select Case strSearchBy Case "BothNames" strSearchBy = _ "SELECT * FROM PatientInfo WHERE FName = " & _ Chr(34) & varOne & Chr(34) & "AND LName = " & _ Chr(34) & varTwo & Chr(34) Case "FName" strSearchBy = _ "SELECT * FROM PatientInfo WHERE FName = " & _ Chr(34) & varOne & Chr(34) Case "LName" strSearchBy = _ "SELECT * FROM PatientInfo WHERE LName = " & _ Chr(34) & varTwo & Chr(34) Case "RecNum" strSearchBy = _ "SELECT * FROM PatientInfo WHERE PatientID = " & varOne End Select funcGetPatientQueryString = strSearchBy GoTo Done Handler: gstrErrorString = "funcGetPatientQueryString:Main" ErrorLog gstrErrorString Done: End Function Dian D. Chapman Technical Consultant, Microsoft MVP & Instructor Free Tutorials: www.mousetrax.com/techtrax Free Word Tips & Tricks eBook: www.mousetrax.com/books.html Learn VBA the easy way, thru video! www.mousetrax.com/techcourses.html -----Original Message----- From: mso-bounce@xxxxxxxxxxxxx [mailto:mso-bounce@xxxxxxxxxxxxx] On Behalf Of James LaBorde Sent: Tuesday, October 14, 2003 3:55 PM To: 'mso@xxxxxxxxxxxxx' Subject: [mso] Re: Access VBA SQL :VSMail mx3 Dian, The only reason for all the parts is so that he can loop through and reuse the same sql with a different where clause each time. James -----Original Message----- From: Dian Chapman [mailto:dian@xxxxxxxxxxxxx] Sent: Monday, October 13, 2003 6:10 PM To: mso@xxxxxxxxxxxxx Subject: [mso] Re: Access VBA SQL :VSMail mx3 See what I mean!<g> All that stuff you wrote make SOME sense to me...but none of it would really be what I would use via ADO. I'd simply connect to the DB, open an RS with a quick SQL query and pull what I needed from the RS. You use a lot more parts than I would for a query. Dian D. Chapman Technical Consultant, Microsoft MVP & Instructor Free Tutorials: www.mousetrax.com/techtrax Free Word Tips & Tricks eBook: www.mousetrax.com/books.html Learn VBA the easy way, thru video! www.mousetrax.com/techcourses.html -----Original Message----- From: mso-bounce@xxxxxxxxxxxxx [mailto:mso-bounce@xxxxxxxxxxxxx] On Behalf Of James LaBorde Sent: Monday, October 13, 2003 12:00 PM To: 'mso@xxxxxxxxxxxxx' Subject: [mso] Re: Access VBA SQL :VSMail mx2 Ray, Not sure of how it would be used in the Excel sense of the word but since you are using VBA, you can open the querydef if you have it in Access and modify it. If the fields are always the same but have different criteria, you can write the querydef on the fly. Here is what I would do: Dim strSQLRoot as string Dim strSQLWhere as String Dim strSQL as String Dim QD as querydef Set QD strSQLRoot = Enter your query here without the where. strSQLWhere = Create your where clause on the fly strSQL = strSQLRoot & strSQLWhere qd = strSQL This will dynamically change your query from your code. This is a very rudimentary look at it, if you want more detail just let me know and I will gladly work with you on it. James -----Original Message----- From: Ray Blake [mailto:ray@xxxxxxxxx] Sent: Monday, October 13, 2003 9:40 AM To: mso@xxxxxxxxxxxxx Subject: [mso] Access VBA SQL :VSMail mx2 Folks, An odd one, this. I'm convinced I've done 90% of the hard work, but my naivety of Access is letting me down at the final step. Here's what I've done: 1. I have a form with a number of listboxes, allowing users to multiple select from several filtering options. 2. I have a big VBA sub which looks at the selections in the listboxes and writes part of an SQL string (basically, the 'WHERE' section), which can be quite long! 3. I now want to use this as the criterion for an existing query, let's call it 'qryFiltered' I just need to know how to accomplish part 3 of the operation. I'm using Access 2000, and have no need to make it 97 compatible. NB: Just reviewed this post and realise my use of the word 'Filter' may confuse the issue - best to clarify that I mean it in the Excel sense of the word. TIA. Ray _____________ This email is from Ray Blake, Head of Software Design, GR Business Process Solutions. It is confidential and intended for the addressee only. The contents are private and may be legally privileged. If you receive this email in error we would be grateful if you would advise the sender and delete the email from your system. For more information on the services that we offer please visit us at our website: - www.grbps.com ************************************************************* You are receiving this mail because you subscribed to mso@xxxxxxxxxxxxx or MicrosoftOffice@xxxxxxxxxxxxxxxx To send mail to the group, simply address it to mso@xxxxxxxxxxxxx To Unsubscribe from this group, send an email to mso-request@xxxxxxxxxxxxx with the word "unsubscribe" (without the quotes) in the subject line. Or, visit the group's homepage and use the dropdown menu. This will also allow you to change your email settings to digest or vacation (no mail). //www.freelists.org/webpage/mso To be able to use the files section for sharing files with the group, send a request to mso-moderators@xxxxxxxxxxxxx and you will be sent an invitation with instructions. Once you are a member of the files group, you can go here to upload/download files: http://www.smartgroups.com/vault/msofiles ************************************************************* ************************************************************* You are receiving this mail because you subscribed to mso@xxxxxxxxxxxxx or MicrosoftOffice@xxxxxxxxxxxxxxxx To send mail to the group, simply address it to mso@xxxxxxxxxxxxx To Unsubscribe from this group, send an email to mso-request@xxxxxxxxxxxxx with the word "unsubscribe" (without the quotes) in the subject line. Or, visit the group's homepage and use the dropdown menu. This will also allow you to change your email settings to digest or vacation (no mail). //www.freelists.org/webpage/mso To be able to use the files section for sharing files with the group, send a request to mso-moderators@xxxxxxxxxxxxx and you will be sent an invitation with instructions. Once you are a member of the files group, you can go here to upload/download files: http://www.smartgroups.com/vault/msofiles ************************************************************* ************************************************************* You are receiving this mail because you subscribed to mso@xxxxxxxxxxxxx or MicrosoftOffice@xxxxxxxxxxxxxxxx To send mail to the group, simply address it to mso@xxxxxxxxxxxxx To Unsubscribe from this group, send an email to mso-request@xxxxxxxxxxxxx with the word "unsubscribe" (without the quotes) in the subject line. Or, visit the group's homepage and use the dropdown menu. This will also allow you to change your email settings to digest or vacation (no mail). //www.freelists.org/webpage/mso To be able to use the files section for sharing files with the group, send a request to mso-moderators@xxxxxxxxxxxxx and you will be sent an invitation with instructions. Once you are a member of the files group, you can go here to upload/download files: http://www.smartgroups.com/vault/msofiles ************************************************************* ************************************************************* You are receiving this mail because you subscribed to mso@xxxxxxxxxxxxx or MicrosoftOffice@xxxxxxxxxxxxxxxx To send mail to the group, simply address it to mso@xxxxxxxxxxxxx To Unsubscribe from this group, send an email to mso-request@xxxxxxxxxxxxx with the word "unsubscribe" (without the quotes) in the subject line. Or, visit the group's homepage and use the dropdown menu. This will also allow you to change your email settings to digest or vacation (no mail). //www.freelists.org/webpage/mso To be able to use the files section for sharing files with the group, send a request to mso-moderators@xxxxxxxxxxxxx and you will be sent an invitation with instructions. Once you are a member of the files group, you can go here to upload/download files: http://www.smartgroups.com/vault/msofiles ************************************************************* ************************************************************* You are receiving this mail because you subscribed to mso@xxxxxxxxxxxxx or MicrosoftOffice@xxxxxxxxxxxxxxxx To send mail to the group, simply address it to mso@xxxxxxxxxxxxx To Unsubscribe from this group, send an email to mso-request@xxxxxxxxxxxxx with the word "unsubscribe" (without the quotes) in the subject line. Or, visit the group's homepage and use the dropdown menu. This will also allow you to change your email settings to digest or vacation (no mail). //www.freelists.org/webpage/mso To be able to use the files section for sharing files with the group, send a request to mso-moderators@xxxxxxxxxxxxx and you will be sent an invitation with instructions. Once you are a member of the files group, you can go here to upload/download files: http://www.smartgroups.com/vault/msofiles ************************************************************* ************************************************************* You are receiving this mail because you subscribed to mso@xxxxxxxxxxxxx or MicrosoftOffice@xxxxxxxxxxxxxxxx To send mail to the group, simply address it to mso@xxxxxxxxxxxxx To Unsubscribe from this group, send an email to mso-request@xxxxxxxxxxxxx with the word "unsubscribe" (without the quotes) in the subject line. Or, visit the group's homepage and use the dropdown menu. This will also allow you to change your email settings to digest or vacation (no mail). //www.freelists.org/webpage/mso To be able to use the files section for sharing files with the group, send a request to mso-moderators@xxxxxxxxxxxxx and you will be sent an invitation with instructions. Once you are a member of the files group, you can go here to upload/download files: http://www.smartgroups.com/vault/msofiles ************************************************************* ************************************************************* You are receiving this mail because you subscribed to mso@xxxxxxxxxxxxx or MicrosoftOffice@xxxxxxxxxxxxxxxx To send mail to the group, simply address it to mso@xxxxxxxxxxxxx To Unsubscribe from this group, send an email to mso-request@xxxxxxxxxxxxx with the word "unsubscribe" (without the quotes) in the subject line. Or, visit the group's homepage and use the dropdown menu. This will also allow you to change your email settings to digest or vacation (no mail). //www.freelists.org/webpage/mso To be able to use the files section for sharing files with the group, send a request to mso-moderators@xxxxxxxxxxxxx and you will be sent an invitation with instructions. Once you are a member of the files group, you can go here to upload/download files: http://www.smartgroups.com/vault/msofiles *************************************************************