techkenny1
Technical User
Hi all,
I have a client form on which resides a combobox (for convienience) which has on the Row source:
"SELECT QBroker.Companyname, QBroker.BrokerStaffID FROM QBroker"
What I want to do is to be able to select the company from the combobox and insert it into another form which has a text box "company"
I have tried using this code but I can not get it to work;
Private Sub cboInvoice_AfterUpdate()
On Error Resume Next
Dim rs As ADODB.Recordset
Dim strSQL As String
cboInvoice.SetFocus
If cboInvoice.Value > 0 Then
strSQL = "SELECT * FROM QBroker WHERE Brokerstaffid = " & cboInvoice.Value
Set rs = CreateObject("ADODB.Recordset")
rs.CursorType = adOpenKeyset
rs.LockType = adLockOptimistic
rs.Open strSQL, CurrentProject.Connection
If rs.State = 1 Then
If Not rs.BOF Then
Me.BrokerStaffID = rs("Brokerstaffid")
Me.Companyname = rs("Companyname")
End If
rs.Close
End If
Set rs = Nothing
End If
Docmd.openForm "Invoice"
End Sub
Any help wpuld be appreciated to get this to work
I have a client form on which resides a combobox (for convienience) which has on the Row source:
"SELECT QBroker.Companyname, QBroker.BrokerStaffID FROM QBroker"
What I want to do is to be able to select the company from the combobox and insert it into another form which has a text box "company"
I have tried using this code but I can not get it to work;
Private Sub cboInvoice_AfterUpdate()
On Error Resume Next
Dim rs As ADODB.Recordset
Dim strSQL As String
cboInvoice.SetFocus
If cboInvoice.Value > 0 Then
strSQL = "SELECT * FROM QBroker WHERE Brokerstaffid = " & cboInvoice.Value
Set rs = CreateObject("ADODB.Recordset")
rs.CursorType = adOpenKeyset
rs.LockType = adLockOptimistic
rs.Open strSQL, CurrentProject.Connection
If rs.State = 1 Then
If Not rs.BOF Then
Me.BrokerStaffID = rs("Brokerstaffid")
Me.Companyname = rs("Companyname")
End If
rs.Close
End If
Set rs = Nothing
End If
Docmd.openForm "Invoice"
End Sub
Any help wpuld be appreciated to get this to work