B
bubbadahut
I'm not sure what to ask here, but I am wondering if there is a way to make this work. I have several order forms which require the same info and I
am trying to get the following code to work so that I can just call it from a function for all the forms. What is going on here is, the user is
selecting an order type from a list and opening the corresponding form. All the form names have the same syntax in the name "frm (type ie. RFR, MRO,
etc.) Head" If I can get this code to work, I can use the same code in a function, no matter which order type they choose.
Private Sub cmdSelect_Click()
On Error GoTo cmdSelect_Click_Err
Dim strOrderType As String
Dim frmName As String
strOrderType = Me![Type]
frmName = "frm" & strOrderType & "Head"
DoCmd.SetWarnings False
DoCmd.OpenForm frmName, acNormal, "", "", acAdd, acNormal 'the code works to this point
' this is where it begins to break down, I get the message that access can't find the form "frmName"
' Is there a way to get it to recognize the string "frmName" here?
Forms!frmName.fldOrderDt = Date
Forms!frmName.fldRequisitioner = Forms!frmLogged!txtFullName
DoCmd.RunSQL "UPDATE tblOrderType SET tblOrderType.fldNextNum = [tblOrderType]![fldNextNum]+1 WHERE
(((tblOrderType.fldOrderType)=[Forms]![frmOrderType]![Type]));", 0
Forms!frmName.cmboStatus = "Unissued"
DoCmd.Close acForm, "frmOrderType"
DoCmd.SetWarnings True
End Select
would appreicate any help here
thanks
greg
am trying to get the following code to work so that I can just call it from a function for all the forms. What is going on here is, the user is
selecting an order type from a list and opening the corresponding form. All the form names have the same syntax in the name "frm (type ie. RFR, MRO,
etc.) Head" If I can get this code to work, I can use the same code in a function, no matter which order type they choose.
Private Sub cmdSelect_Click()
On Error GoTo cmdSelect_Click_Err
Dim strOrderType As String
Dim frmName As String
strOrderType = Me![Type]
frmName = "frm" & strOrderType & "Head"
DoCmd.SetWarnings False
DoCmd.OpenForm frmName, acNormal, "", "", acAdd, acNormal 'the code works to this point
' this is where it begins to break down, I get the message that access can't find the form "frmName"
' Is there a way to get it to recognize the string "frmName" here?
Forms!frmName.fldOrderDt = Date
Forms!frmName.fldRequisitioner = Forms!frmLogged!txtFullName
DoCmd.RunSQL "UPDATE tblOrderType SET tblOrderType.fldNextNum = [tblOrderType]![fldNextNum]+1 WHERE
(((tblOrderType.fldOrderType)=[Forms]![frmOrderType]![Type]));", 0
Forms!frmName.cmboStatus = "Unissued"
DoCmd.Close acForm, "frmOrderType"
DoCmd.SetWarnings True
End Select
would appreicate any help here
thanks
greg