Steve R.
Retired
- Local time
- Today, 06:11
- Joined
- Jul 5, 2006
- Messages
- 5,652
My understanding of passing a variable directly from to a popup form is incomplete. The following code works, but requires an "unnecessary" variable assignment.
The popup is called with the following code. However, because I have been unable to pass stUnderLyingfrm and stRecordSource to the popup form, I am using a subroutine. Rather than have two popup forms, I am trying to use one, which is why I am trying to pass the record source. All these variables have been defined as PUBLIC in the declaration section.
Below is the subroutine. For some reason, I must pass the variable intBookId to intBook01id for the program to work, but this should not be necessary which means that I am not understanding something.
Partial sample from the popup form to show how stRecordSource01 is used. Ideally, I should be able to reference stRecordSource directly, but I must be missing something somewhere.
The popup is called with the following code. However, because I have been unable to pass stUnderLyingfrm and stRecordSource to the popup form, I am using a subroutine. Rather than have two popup forms, I am trying to use one, which is why I am trying to pass the record source. All these variables have been defined as PUBLIC in the declaration section.
Code:
Public Sub Command72_Click()
intBookId = Me.BOOKID
stUnderLyingfrm = Me.Name
stRecordSource = "Qalpha"
Rem stDocName = "IMAGEADDFRM"
Rem stLinkCriteria = "BOOKID= " & intBookId
Rem DoCmd.OpenForm stDocName, acNormal, , stLinkCriteria, ,acDialog
Call IMAGEADD(intBookId, stUnderLyingfrm, stRecordSource)
End Sub
Below is the subroutine. For some reason, I must pass the variable intBookId to intBook01id for the program to work, but this should not be necessary which means that I am not understanding something.
Code:
Public Sub IMAGEADD(intBookId As Integer, stUnderLyingfrm As String, stRecordSource As String)
intBook01id = intBookId
stUnderLying01frm = stUnderLyingfrm
stRecordSource01 = stRecordSource
stDocName = "IMAGEADDFRM"
stLinkCriteria = "BOOKID= " & intBookId
DoCmd.OpenForm stDocName, acNormal, , stLinkCriteria, , acDialog
End Sub
Partial sample from the popup form to show how stRecordSource01 is used. Ideally, I should be able to reference stRecordSource directly, but I must be missing something somewhere.
Code:
Public Sub Form_Open(Cancel As Integer)
stDocName = Me.Name
Forms(stDocName).RecordSource = stRecordSource01
Forms(stDocName).AllowAdditions = False
End Sub