Line 2 ( Me.Bathroom = Forms!frmBathrooms!ID ) is tripping the error. Debugger says Me.Bathroom = 1, Forms!frmBathrooms!ID = 38. Basically I'm trying to automatically make this form's Bathroom field match that of the frmBathrooms form's ID. "Me" is a form for items in the bathroom; there can be many items.
How the hell is that throwing an error? I can't find anything dispite about an hour of searching around. I understand the message, but not how this could be throwing it?
The Bathroom field of the Item table is in the form's recordsource, etc. Ideas?
Code:
Private Sub Form_Open(Cancel As Integer)
Me.Bathroom = Forms!frmBathrooms!ID
Me.txtBathInfo.Caption = "Bathroom Room Number: " & DLookup("Room", "tblRooms", "ID = " & DLookup("Room", "tblBathrooms", "ID = " & Me.Bathroom))
Me.RecordSource = "SELECT * FROM tblStalls WHERE Bathroom = " & Me.Bathroom
Me.Recordset.AddNew
End Sub
FIXED:
Code:
Private Sub Form_Open(Cancel As Integer)
Me.RecordSource = "SELECT * FROM tblStalls WHERE Bathroom = " & Forms!frmBathrooms!ID
Me.Recordset.AddNew
Me.Bathroom = Forms!frmBathrooms!ID
Me.txtBathInfo.Caption = "Bathroom Room Number: " & DLookup("Room", "tblRooms", "ID = " & DLookup("Room", "tblBathrooms", "ID = " & Me.Bathroom))
End Sub
Just have to add the new stuff first, then change the values.