techkenny1
Technical User
Hi,
On a form I have a combobox with data.
What I want to do is that' when the data in a 'field' is changed via the combobox, the back colour changes on that 'field' so that the changes are visible. The code I use for this is as follows;
On the after update of the combobox
Dim rs As ADODB.Recordset
Dim strSQL As String
cboCompanyname.SetFocus
If cboCompanyname.Value > 0 Then
strSQL = "SELECT * FROM QBroker WHERE Brokerstaffid = " & cboCompanyname.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")
Me.BDr = rs("BDR")
Me.BNR = rs("BNR")
Me.BSatR = rs("BSATR")
Me.BSunR = rs("BSUNR")
Me.BPwknR = rs("BPWKNR")
Me.BPHR = rs("BPHR")
Me.BPWndR = rs("BPWNDR")
Me.BSpec = rs("BSPEC")
End If
rs.Close
End If
Set rs = Nothing
Many thanks
On a form I have a combobox with data.
What I want to do is that' when the data in a 'field' is changed via the combobox, the back colour changes on that 'field' so that the changes are visible. The code I use for this is as follows;
On the after update of the combobox
Dim rs As ADODB.Recordset
Dim strSQL As String
cboCompanyname.SetFocus
If cboCompanyname.Value > 0 Then
strSQL = "SELECT * FROM QBroker WHERE Brokerstaffid = " & cboCompanyname.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")
Me.BDr = rs("BDR")
Me.BNR = rs("BNR")
Me.BSatR = rs("BSATR")
Me.BSunR = rs("BSUNR")
Me.BPwknR = rs("BPWKNR")
Me.BPHR = rs("BPHR")
Me.BPWndR = rs("BPWNDR")
Me.BSpec = rs("BSPEC")
End If
rs.Close
End If
Set rs = Nothing
Many thanks