Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

OpenRecordset SQL Statement Does Not Fit

Status
Not open for further replies.
Apr 9, 2002
102
0
0
US
I am using an SQL statement in my OpenRecordset and for some reason it does not take the whole statement. It cuts the statement off towards the end. Is there any way around this? Below is my code. Thanks.

Public Sub Exporter(DivisionNumber As Single, RegionName As String, CycleName As String)

Dim dbs As DAO.Database
Dim rs As DAO.Recordset

Set dbs = CurrentDb
Set rs = dbs.OpenRecordset("Select [divname], [divcode], [regname], [cycname], [actname], [tblactivity].[actnum], [actdesc], [objname], [tblobjective].[objnum], [objdesc], [empname], [empnum] FROM qryresponsibilityfulldetail WHERE [divcode] = '" & DivisionNumber & "' and [regname] = " & """" & RegionName & """" & " and [cycname] = " & """" & CycleName & """" & ";", dbOpenDynaset)

End Sub
 
Is this part correct: [regname] = " & """" & RegionName & """"

What's with all the double quote marks? Are these actually stored in your tables?
 
Yes, that part is correct. By placing """" before and after RegionName, I am making the final SQL statement look like this: [regname] = "Mexico". That portion of the SQL statement is correct because I am calling for the value of a variable (RegionName).

Marrow
 
Please disregard this post. I just found that I was only looking at the name of the recordset and not the full SQL statement used to populate it. Sorry to waste your time.

Marrow
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top