Good day,
I have a combo box with a Row Source Type as Value list and Yes;No as row source. If a user selects Yes, it will save the value "Yes" in my table and then opens form. And if its a No it will just go to next control.
Good day,
I have a combo box with a Row Source Type as Value list and Yes;No as row source. If a user selects Yes, it will save the value "Yes" in my table and then opens form. And if its a No it will just go to next control.
In the after update event of the combo:
Code:If Me.ComboName = "Yes" Then DoCmd.OpenForm... End If
If the combobox is bound to a Yes/No field type in a table...
Typically with a combobox that's bound on a Yes/No field type, for the value list, you have:
-1;Yes;0;No
and set the columncount to 2 and the column width's to 0";.75"
This then saves a -1 or 0 into the Yes/No field in the table.
If it's not bound to a field, then disregard and follow as pbaldy stated to open the form.
Both replies works perfectly.
However, once the form has been loaded and completed the data entry ..I received this message "You cannot add or change a record because a related record is required in table "tableName'. Its something to do with the EmpID in Table2 (opened form) not being replicated. Please note that EmpID field in table1 (w/ Primary key)and table2 has a one-To-Many relationship. Please help.
It sounds like the record in the first form might not be saved yet? If not, add this right before opening the other form:
If Me.Dirty Then Me.Dirty = False
pbaldy,
yes you're right the record in not yet saved in the first form, the combo box is my 3rd field (out of 10). Which event would I use to place the code for the other form, I'm lost.
You'd place that line immediately before the OpenForm line.
Hi pbaldy,
I'm still getting the same error.
Code:Private Sub Group_Click() If Me.Group = True Then If Me.Dirty Then Me.Dirty = False DoCmd.OpenForm "frmSpouse" End If End Sub
You're getting the error on the second form, right (frmSpouse)? Has whatever field that relates that form to the first been added to the first yet? Has there been enough added to the first for the record to save (missing required fields)?
pbaldy,
I only get the error on the frmSpouse, please see attached sample file.
It's because frmSpouse doesn't have the employee ID. Try this:
The first bit will open the form with any existing matching records, the second will force the employee ID from the first form. Play with those and see how it goes.Code:If cboGroup.Value = "1" Then DoCmd.OpenForm "frmSpouse", , , "EmpID = " & Me.EmpID Forms!frmSpouse.EmpID = Me.EmpID End If
I'm getting a "Run-time error '2465' Application-defined or object-defined error" in line:
Forms!frmSpouse2.EmpID = Me.EmpID
Where do you have it? I copied that out of your db after I tested it.
pbaldy.
I just created a subform and apply the code and works perfectly.
Glad you got it sorted out.