T
TonyWilliams via AccessMonster.com
I have an unbound form which has a unbound combox box called cmbmonth where
the user chooses a value from the list for which the record source is based
on this SQL statement
SELECT tblMonth.txtmonthlabela
FROM tblMonth
ORDER BY tblMonth.txtmonthlabela DESC;
txtmonthlabela is a date field - (I realise that the name is totally
misleading but that's how I it was when I got it!)
There is then a command button which should open a form which has a control
called txtmonth, a date field. However when I click on the form it doesn't
show any records. Here is the code behind the button.
Private Sub cmdopenrecord_Click()
On Error GoTo Err_cmdopenrecord_Click
Dim strtxtdate As Date
strtxtdate = Me.cmbmonth.Value
Forms!frmMain!SubForm1.SourceObject = "frmhighvaluedeals"
Forms!frmMain!SubForm1.Form.RecordSource = _
"SELECT * FROM [tblhvcomp] " & _
"WHERE [txtmonth] = #" & Format(strtxtdate, "mmmm/yyyy") & "#"
Exit_cmdopenrecord_Click:
Exit Sub
Err_cmdopenrecord_Click:
MsgBox Err.Description
Resume Exit_cmdopenrecord_Click
End Sub
Can anyone point me in the right direction as to why no records are being
shown?
Thanks
Tony
the user chooses a value from the list for which the record source is based
on this SQL statement
SELECT tblMonth.txtmonthlabela
FROM tblMonth
ORDER BY tblMonth.txtmonthlabela DESC;
txtmonthlabela is a date field - (I realise that the name is totally
misleading but that's how I it was when I got it!)
There is then a command button which should open a form which has a control
called txtmonth, a date field. However when I click on the form it doesn't
show any records. Here is the code behind the button.
Private Sub cmdopenrecord_Click()
On Error GoTo Err_cmdopenrecord_Click
Dim strtxtdate As Date
strtxtdate = Me.cmbmonth.Value
Forms!frmMain!SubForm1.SourceObject = "frmhighvaluedeals"
Forms!frmMain!SubForm1.Form.RecordSource = _
"SELECT * FROM [tblhvcomp] " & _
"WHERE [txtmonth] = #" & Format(strtxtdate, "mmmm/yyyy") & "#"
Exit_cmdopenrecord_Click:
Exit Sub
Err_cmdopenrecord_Click:
MsgBox Err.Description
Resume Exit_cmdopenrecord_Click
End Sub
Can anyone point me in the right direction as to why no records are being
shown?
Thanks
Tony