T
Tony Williams
I have a subform with a date called txtmontha with a format mmmm/yyyy There
is also a command button that when clicked should open another subform which
has a date txtmonthlabela, also format as mmm/yyyy. The command button should
open the sub form for all records when the value of txtmontha and
txtmonthlabela are the same. However when I click on the command button
although the form opens I get a prompt box asking me for the value of
txtmonthlabela. If I cancel the prompt box the form opens with a number of
records shown in the record selector box at the foot of the form but no data
is shown in the controls on the form.
Here is my code:
Private Sub cmdopenrecord_Click()
On Error GoTo Err_cmdopenrecord_Click
Dim strtxtdate As Date
strtxtdate = Me.txtmontha.Value
Forms!frmMain!SubForm1.SourceObject = "frmFDA"
Forms!frmMain!SubForm1.Form.RecordSource = "SELECT * FROM [tblmaintabs]
WHERE [txtmonthlabela] = #" & Format(strtxtdate, "mmmm/yyyy") & "#;"
Exit_cmdopenrecord_Click:
Exit Sub
Err_cmdopenrecord_Click:
MsgBox Err.Description
Resume Exit_cmdopenrecord_Click
End Sub
Can anyone suggest what the problem may be?
Thanks
Tony
is also a command button that when clicked should open another subform which
has a date txtmonthlabela, also format as mmm/yyyy. The command button should
open the sub form for all records when the value of txtmontha and
txtmonthlabela are the same. However when I click on the command button
although the form opens I get a prompt box asking me for the value of
txtmonthlabela. If I cancel the prompt box the form opens with a number of
records shown in the record selector box at the foot of the form but no data
is shown in the controls on the form.
Here is my code:
Private Sub cmdopenrecord_Click()
On Error GoTo Err_cmdopenrecord_Click
Dim strtxtdate As Date
strtxtdate = Me.txtmontha.Value
Forms!frmMain!SubForm1.SourceObject = "frmFDA"
Forms!frmMain!SubForm1.Form.RecordSource = "SELECT * FROM [tblmaintabs]
WHERE [txtmonthlabela] = #" & Format(strtxtdate, "mmmm/yyyy") & "#;"
Exit_cmdopenrecord_Click:
Exit Sub
Err_cmdopenrecord_Click:
MsgBox Err.Description
Resume Exit_cmdopenrecord_Click
End Sub
Can anyone suggest what the problem may be?
Thanks
Tony