form name not object name standard

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

with the following code:

sqlstr1 = "select filelocation,menulabellocation, menuid from menus where
menuname = '" & txtMenuName & "'"
Set rs2 = CurrentDb.OpenRecordset(sqlstr1)
txtMenuLocation = rs2!FileLocation
txtMenuLabel = rs2!MenuLabelLocation
'rs2.Close
subfrmMenuDates.Visible = True
'subfrmMenuDates.LinkChildFields = "menus!MenuID"
'subfrmMenuDates.LinkMasterFields = "menuwhenused!MenuID"
subfrmMenuDates.SourceObject = "SELECT MonthYear.Month, MonthYear.Year,
MenuWhenUsed.MenuID" & _
" FROM MenuWhenUsed INNER JOIN MonthYear ON MenuWhenUsed.MonthYearID =
MonthYear.DateID" & _
" Where MenuWhenUsed.MenuID = " & rs2!MenuID

rs2.Close

a blow up occurs at subfrmmenudates.sourceobject with this message:

the form name you entered doesn't follow Microsoft Access object naming rules.

Any wisdom would be great.
 
It looks as though you're trying to set the RecordSource for the subform.
Assuming that's correct, try:

subfrmMenuDates.Form.RecordSource = _
"SELECT MonthYear.Month, MonthYear.Year, " & _
"MenuWhenUsed.MenuID FROM MenuWhenUsed INNER JOIN MonthYear " & _
"ON MenuWhenUsed.MonthYearID = MonthYear.DateID" & _
" Where MenuWhenUsed.MenuID = " & rs2!MenuID

The SourceObject property is actually the name of the form being used as a
subform, and your SQL statement certainly doesn't following the naming rules
for a form! <g>
 
I now get this message.

you entered an expression that has an invalid reference to the property
recordsource.

Thank you for your input. I will look forward to further comment.
 
I was assuming that subfrmMenuDates was the name of the subform control on
your main form. If that's not the case, what is it?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top