Hello Group,
In access 2003/VBA environment, I am trying to take a value from a combo box and use in the WHERE clause in a query and open the query as a recordset. But it throws an error "No value given for one or more required parameters" . It prints out the value from the combo correctly. The problem starts when it tries to open the recordset. The query looks simple and correct to me, may be I am passing wrong arguments to the recordset object.
Here is my code:
Dim strsql As String
Dim rst As ADODB.Recordset
Set rst = New ADODB.Recordset
MsgBox Forms![Test Form]![Area]
strsql = "Select Aid from Area where [Area] = Forms![Test Form]![area]"
rst.Open strsql, CurrentProject.Connection, adOpenStatic
MsgBox rst.RecordCount
rst.Close
Set rst = Nothing
Appreciate any help in this regard.
Thanks,
Pradeep
In access 2003/VBA environment, I am trying to take a value from a combo box and use in the WHERE clause in a query and open the query as a recordset. But it throws an error "No value given for one or more required parameters" . It prints out the value from the combo correctly. The problem starts when it tries to open the recordset. The query looks simple and correct to me, may be I am passing wrong arguments to the recordset object.
Here is my code:
Dim strsql As String
Dim rst As ADODB.Recordset
Set rst = New ADODB.Recordset
MsgBox Forms![Test Form]![Area]
strsql = "Select Aid from Area where [Area] = Forms![Test Form]![area]"
rst.Open strsql, CurrentProject.Connection, adOpenStatic
MsgBox rst.RecordCount
rst.Close
Set rst = Nothing
Appreciate any help in this regard.
Thanks,
Pradeep