Hi all, hope someone can point out the schoolboy error I'm probably making here
I have a button on a form, formA, when I click this button it opens a new form, form B. Data entered on form B is displayed as a summary on form A in continuous sheet style. Form B has a button it so that when I've finished entering my information, clicking the button will write the record, requery the Form A, and move the cursor to the last record, i.e. the one just created in form B, to give visual confirmation. Thing is, I have 6 different versions of formA, which form B can service. However, for the requery and goto last record to function I need to be specific on the name of the form. A typical form name is frmBookT101 where T101 is field Room Number. The field Room Number appears on form B, so I've tried to concatenate a string from "frmBook" and the value of field Room Number displayed on form B, as below:
Private Sub Make_Booking_Click()
On Error GoTo Err_Make_Booking_Click
Dim strName As String
strName = "frmBook" & Me![Room Number]
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
Forms![strName].Requery
DoCmd.GoToRecord acDataForm, "strName", acLast
Exit_Make_Booking_Click:
Exit Sub
Err_Make_Booking_Click:
MsgBox Err.Description
Resume Exit_Make_Booking_Click
End Sub
On form B field Room Number is selected from a combo box, if this is relevant.
I keep getting an error message saying that the form"strName" cannot be found.
Where am i going wrong?
Thanks, Lol

I have a button on a form, formA, when I click this button it opens a new form, form B. Data entered on form B is displayed as a summary on form A in continuous sheet style. Form B has a button it so that when I've finished entering my information, clicking the button will write the record, requery the Form A, and move the cursor to the last record, i.e. the one just created in form B, to give visual confirmation. Thing is, I have 6 different versions of formA, which form B can service. However, for the requery and goto last record to function I need to be specific on the name of the form. A typical form name is frmBookT101 where T101 is field Room Number. The field Room Number appears on form B, so I've tried to concatenate a string from "frmBook" and the value of field Room Number displayed on form B, as below:
Private Sub Make_Booking_Click()
On Error GoTo Err_Make_Booking_Click
Dim strName As String
strName = "frmBook" & Me![Room Number]
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
Forms![strName].Requery
DoCmd.GoToRecord acDataForm, "strName", acLast
Exit_Make_Booking_Click:
Exit Sub
Err_Make_Booking_Click:
MsgBox Err.Description
Resume Exit_Make_Booking_Click
End Sub
On form B field Room Number is selected from a combo box, if this is relevant.
I keep getting an error message saying that the form"strName" cannot be found.
Where am i going wrong?
Thanks, Lol
