Dim myConnection As ADODB.Connection
Dim myRecordSet As New ADODB.Recordset
Dim strSQL As String
strSQL = Trim(Replace(Me.cboSpecific01.RowSource, ";", ""))
Debug.Print strSQL
Set myConnection = CurrentProject.Connection
myRecordSet.ActiveConnection = myConnection
myRecordSet.Open strSQL, , adOpenStatic
If myRecordSet.RecordCount > 1 Then
Me.cboSpecific01.Visible = True
Me.cboSpecific01 = Null
Else
Me.cboSpecific01.Visible = False
Me.txtResult = myRecordSet.Fields(3).Value
Me.txtResult.Visible = True
Me.txtResult.Requery
myRecordSet.Close
End If
so if the next combo box (cboSpecific01) will only contain one record,
it is not shown and instead txtResult displays this final answer. If
it contains more than one choice, the next combo box (cboSpecific01)
is displayed.
For the above case, strSQL contains "SELECT DISTINCT
tblSpecifics.Specific01 FROM tblSpecifics WHERE (([Condition]=Forms!
frmMain!cboCondition)); ".
When I run the code I get the following message: "Run time error
'-2147217904 (80040e10)': No value given for one or more required
parameters" and the myrecordset.open line is highlighted. Before this
I tried using a DCount function instead of recordsets but I couldn't
get this to work either: I just got a "You cancelled the previous
operation" error message.
Can anyone see where I am going wrong? Any help would be much
appreciated.
little typo in the above post - the semicolon is obviously removed in
strSQL!