S
sheela
Hi:
I am trying to run the following code under a command
button click event:
But this code is always giving an error with "error number
3061: Too few parameters, expected 3".
The Sql statements syntax and the field names are correct.
I could run this query from query wizard with out any
errors.
I suspect, that I am missing something with openrecordset
property, but couldn't figure out.
Could some one please help me with this?
TIA,
Sheela
Private Sub cmdSaveClose_Click()
Dim k As Integer
Dim dbs As Database
Dim rstSQLpositionexists As Recordset
On Error GoTo Err_cmdSaveClose_Click
Set dbs = CurrentDb
Set rstSQLpositionexists = dbs.OpenRecordset("SELECT
tablename.RecordID FROM tablename WHERE
(((tablename.FreezerName)=[Forms]![formname]!
[cmbFreezerName]) AND
...
and tablename.Position between [Forms]![formname]!
[txtStartPosition.Value And [Forms]![formname]!
[.txtEndPosition.Value")
If rstSQLpositionexists.RecordCount > 0 Then
MsgBox ("mesage..")
DoCmd.Close
End If
Statements.
.....
Exit_cmdSaveClose_Click:
Exit Sub
Err_cmdSaveClose_Click:
MsgBox "Error No: " & Err.Number & "; Description: " &
Err.Description
Resume Exit_cmdSaveClose_Click
DoCmd.Close
End Sub
I am trying to run the following code under a command
button click event:
But this code is always giving an error with "error number
3061: Too few parameters, expected 3".
The Sql statements syntax and the field names are correct.
I could run this query from query wizard with out any
errors.
I suspect, that I am missing something with openrecordset
property, but couldn't figure out.
Could some one please help me with this?
TIA,
Sheela
Private Sub cmdSaveClose_Click()
Dim k As Integer
Dim dbs As Database
Dim rstSQLpositionexists As Recordset
On Error GoTo Err_cmdSaveClose_Click
Set dbs = CurrentDb
Set rstSQLpositionexists = dbs.OpenRecordset("SELECT
tablename.RecordID FROM tablename WHERE
(((tablename.FreezerName)=[Forms]![formname]!
[cmbFreezerName]) AND
...
and tablename.Position between [Forms]![formname]!
[txtStartPosition.Value And [Forms]![formname]!
[.txtEndPosition.Value")
If rstSQLpositionexists.RecordCount > 0 Then
MsgBox ("mesage..")
DoCmd.Close
End If
Statements.
.....
Exit_cmdSaveClose_Click:
Exit Sub
Err_cmdSaveClose_Click:
MsgBox "Error No: " & Err.Number & "; Description: " &
Err.Description
Resume Exit_cmdSaveClose_Click
DoCmd.Close
End Sub