How do I get this checkbox to wotk???

Anders

New member
Local time
Today, 16:07
Joined
Apr 13, 2001
Messages
5
I have a form (frmvslsearch). On this form I have a combobox (cbovslnumber). This combobox is linked to a table (tblvessels). In the combobox I can select from the field called 'Vessel number'. When I have selected, another form is activated (frmvslinformation). The textboxes on this form are linked to different fields in the table. The problem is then the checkbox (also on form2 (frmvslinformation). The field to be used in the table is called 'Ongoing'. I have used a 'Yes/No' field (not sure if this is ok!). If the field is marked in the table (Yes/True) then the checkbox should also be marked on 'frmvslinformation', and if it is unmarked in the table, then the same on the form.

Below code is what I have re this:

Private Sub cboVslnumber_AfterUpdate()

Forms("frmvslsearch").Visible = False
DoCmd.OpenForm "frmvslinformation"

'Check the value of the True/False field of the record.
Dim myVal
myVal = DLookup("Vessel number", "tblVessels", "Ongoing = " & "'" & Me.cboVslnumber & "'")
'Assign the value to the checkbox
If Not IsNull(myVal) Then
Me.chkOngoing = CInt(myVal)
End If

End Sub

My problem is that I can't get the checkbox part to work.

I would appreciate any help given.
Thanks.
 
I'm certain you have to use an update query to change a checkbox, change the checkbox to a text box with yes/no as the format and default value to no simply change the value via code to yes if your condition is true.
 
Ok. I have tried that, but I'm having problems getting the Dlookup function to work. When I choose an entry in the combobox, I want it to find that value in the right column, and then check for the value to be used in the checkbox.

Appreciate your help.
 

Users who are viewing this thread

Back
Top Bottom