T
Tony Williams
I have two forms, frma and frmb, both are for inputting new records and are
based on a table, tblmonth, both have two controls, txtmonth and
txtmonthlabela which are based on the fields in the table.
frma has a command button that opens frmb. I want the command buuton to pass
the value of txtmonth and txtmonthlabela from frma to the controls on frmb
I am using this code on the command button on frma:
Private Sub cmdOpenform_Click()
On Error GoTo Err_cmdOpenform_Click
DoCmd.OpenForm "frmb", , , , acFormEdit, , Me.txtMonth
DoCmd.Close acForm, Me.Name
Exit_cmdOpenform_Click:
Exit Sub
Err_cmdOpenform_Click:
MsgBox Err.Description
Resume Exit_cmdOpenform_Click
End Sub
and this code on the onload event of frmb:
Private Sub Form_Load()
If Len(Me.OpenArgs & "") > 0 Then
Me.txtMonth = Me.OpenArgs
Me.txtMonth.SetFocus
End If
End Sub
The code at the moment only passes the value of txtmonth and I want to pass
the value of txtmonthlabela as well. Also because txtmonth has the no
duplicates property set on the field I get an error message to say I can't
create the new record because it already exists.
Can anyone help?
TIA
Tony Williams
based on a table, tblmonth, both have two controls, txtmonth and
txtmonthlabela which are based on the fields in the table.
frma has a command button that opens frmb. I want the command buuton to pass
the value of txtmonth and txtmonthlabela from frma to the controls on frmb
I am using this code on the command button on frma:
Private Sub cmdOpenform_Click()
On Error GoTo Err_cmdOpenform_Click
DoCmd.OpenForm "frmb", , , , acFormEdit, , Me.txtMonth
DoCmd.Close acForm, Me.Name
Exit_cmdOpenform_Click:
Exit Sub
Err_cmdOpenform_Click:
MsgBox Err.Description
Resume Exit_cmdOpenform_Click
End Sub
and this code on the onload event of frmb:
Private Sub Form_Load()
If Len(Me.OpenArgs & "") > 0 Then
Me.txtMonth = Me.OpenArgs
Me.txtMonth.SetFocus
End If
End Sub
The code at the moment only passes the value of txtmonth and I want to pass
the value of txtmonthlabela as well. Also because txtmonth has the no
duplicates property set on the field I get an error message to say I can't
create the new record because it already exists.
Can anyone help?
TIA
Tony Williams