wlwebb
asked on
Access - Tabbed Form - Form to Select Record for Another Tab
Hello All
Continuing the rewrite corrections of moving my separate forms to a Tabbed Form.
On my Main Tab where the clerk will select the reporting type, when they click a Control Button it Inserts a new record in a particular table [ShiftRptgLVLCtl]. That record now needs to be the one selected on the Page2 tab of my tabbed forms.
My tabbed form name is [frm_DataReporting] with a TabControlName of TabCtl_DataReporting.
The user clicks a Control button on the form on tab Name [Page1] page Index 0
I have code that on that click it inserts a new record in the [ShiftRptgLVLCtl] table
I thought... the last line of code would SELECT that new record on the Page2 Tab Index 1
but it errors and tells me:
Runtime error 2580
The record Source SELECT.... , specified on this form or report doesn't exist
Continuing the rewrite corrections of moving my separate forms to a Tabbed Form.
On my Main Tab where the clerk will select the reporting type, when they click a Control Button it Inserts a new record in a particular table [ShiftRptgLVLCtl]. That record now needs to be the one selected on the Page2 tab of my tabbed forms.
My tabbed form name is [frm_DataReporting] with a TabControlName of TabCtl_DataReporting.
The user clicks a Control button on the form on tab Name [Page1] page Index 0
I have code that on that click it inserts a new record in the [ShiftRptgLVLCtl] table
I thought... the last line of code would SELECT that new record on the Page2 Tab Index 1
but it errors and tells me:
Runtime error 2580
The record Source SELECT.... , specified on this form or report doesn't exist
Private Sub NewLVLControl()
Dim lngRptgShiftID As Long, lngShiftSeqID As Long, lngShiftRptgLVLCtlID As Long
lngRptgShiftID = GetMyShiftID()
CurrentDb.Execute "INSERT INTO ShiftReportingLVLCtl (LocationID, LVLRptgTypeID) VALUES (" & Me.txtLocationNbr & "," & Val(Me.cboSelectedLVLRptgType) & ")", dbFailOnError
lngShiftRptgLVLCtlID = DMax("ShiftRptgLVLCtlID", "ShiftReportingLVLCtl", "ShiftRptgLVLCtlID")
Me.txtNewShiftReportingLVLCtl = lngShiftRptgLVLCtlID
lngShiftSeqID = Forms![frm_DataReporting]![WVLVLControlTotals].Form![ShiftRptgLVLCtlID]
Me.txtNewSeqID = lngShiftSeqID
Forms![frm_DataReporting]![WVLVLControlTotals].Form![txtNewShiftPrtgLVLCtlID] = lngShiftRptgLVLCtlID
Me.Parent!WVLVLControlTotals.Form.RecordSource = "SELECT ShiftRptgLVLCtlID FROM ShiftRptgLVLCtl WHERE ShiftRptgLVLCtlID =" & lngShiftRptgLVLCtlID
End Sub
ASKER
Ok, I'm getting closer.... well at least I don't get an error now... Replaced that last line with these two lines...
By the way
Parent.Page4. is Forms![frm_DataReporting]! [frm_Shift ReportingL VL].Form!
Parent.Page4.SetFocus
DoCmd.FindRecord "Forms![frm_DataReporting]![frm_ShiftReportingLVL].Form![ShiftRptgLVLCtlID].txtNewShiftReportingLVLCtl =" & Me.txtNewShiftReportingLVLCtl
By the way
Parent.Page4. is Forms![frm_DataReporting]!
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
fyed,
Thanks for responding. I think I understand that.
First, for the strCriteria, I need to Dim that as String, correct?
Then on the requery,,,,, I put that code after these last two lines
Parent.Page4.SetFocus
Forms![frm_DataReporting]! [ShiftRepo rtingLVL]. Form![AmtO ut].SetFoc us
(these two appear to work because it makes that the visible form and the field AmtOut is the second field and it is the one selected, I used the second field just so I could tell that it was setting the focus instead of defaulting to the first field....
but I'm getting an error:
Run-time error '2465'
Microsoft Office Access can't find the field 'frm_shiftReportingLVL' referred to in you expression.
That seems odd...I checked the spelling of both [] form names and they're correct...
Just as an FYI, originally, that subform had the Name frm_ShiftReportingLVL and Source Object frm_ShiftReportingLVL... when I couldn't get it to work (select the 5 records I wanted) I changed the NAME but not the Object to ShiftReportingLVL.. I would think that's correct but letting you know just in case.......
Thanks for responding. I think I understand that.
First, for the strCriteria, I need to Dim that as String, correct?
Then on the requery,,,,, I put that code after these last two lines
Parent.Page4.SetFocus
Forms![frm_DataReporting]!
(these two appear to work because it makes that the visible form and the field AmtOut is the second field and it is the one selected, I used the second field just so I could tell that it was setting the focus instead of defaulting to the first field....
but I'm getting an error:
Run-time error '2465'
Microsoft Office Access can't find the field 'frm_shiftReportingLVL' referred to in you expression.
That seems odd...I checked the spelling of both [] form names and they're correct...
Just as an FYI, originally, that subform had the Name frm_ShiftReportingLVL and Source Object frm_ShiftReportingLVL... when I couldn't get it to work (select the 5 records I wanted) I changed the NAME but not the Object to ShiftReportingLVL.. I would think that's correct but letting you know just in case.......
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
"I SEE" said the blind man!!!!!!!!!!!! WORKED instantly!!!!!!!!!
Thank you!!!!!! struggled with all kinds of combos because I was grasping at straws
Thank you!!!!!! struggled with all kinds of combos because I was grasping at straws
Glad I could help.
ASKER
I also tried this as the last line of code
Open in new window