Hello:
I am trying to create a DAO record set for the first time. I wanted to keep it simple, so I first wrote something to work for my Division field then I would expand on the code later. Below is what I have in my onClick event:
[code=vb]
'Checks to see if there are records for that given Division, Year, Month, Week Combo.
'If so tells the user to update
rstSQL = "SELECT tblStaticAllFor ecast.DivisionI DFK, " & _
"FROM tblStaticAllFor ecast " & _
"WHERE ((tblStaticAllF orecast.Divisio nIDFK)='" & [Forms]![lock]![cboDivision] & "');"
Dim rs As DAO.Recordset
Set rs = CurrentDb.OpenR ecordset(rstSQL )
recordexists = rst.RecordCount
If Nz(recordexists , 0) > 0 Then
MsgBox "The records that you are trying to lock already exists -- Please select another week or use the update feature."
Else
[/code]
I am getting the following message when I execute:
[code=txt]
The SELECT statement includes a reserved word or an argument name that is misspelled or missing, or the punctuation is incorrect. (Error 3141)
[/code]
The error focuses on the [code=vb] Set rs = CurrentDb.OpenR ecordset(rstSQL ) [/code]. Since I am new at this can anybody see what I am missing? Any help or assistance would be greatly appreciated.
Thanks,
Keith.
I am trying to create a DAO record set for the first time. I wanted to keep it simple, so I first wrote something to work for my Division field then I would expand on the code later. Below is what I have in my onClick event:
[code=vb]
'Checks to see if there are records for that given Division, Year, Month, Week Combo.
'If so tells the user to update
rstSQL = "SELECT tblStaticAllFor ecast.DivisionI DFK, " & _
"FROM tblStaticAllFor ecast " & _
"WHERE ((tblStaticAllF orecast.Divisio nIDFK)='" & [Forms]![lock]![cboDivision] & "');"
Dim rs As DAO.Recordset
Set rs = CurrentDb.OpenR ecordset(rstSQL )
recordexists = rst.RecordCount
If Nz(recordexists , 0) > 0 Then
MsgBox "The records that you are trying to lock already exists -- Please select another week or use the update feature."
Else
[/code]
I am getting the following message when I execute:
[code=txt]
The SELECT statement includes a reserved word or an argument name that is misspelled or missing, or the punctuation is incorrect. (Error 3141)
[/code]
The error focuses on the [code=vb] Set rs = CurrentDb.OpenR ecordset(rstSQL ) [/code]. Since I am new at this can anybody see what I am missing? Any help or assistance would be greatly appreciated.
Thanks,
Keith.
Comment