RobertIngles
Technical User
I have learned a tremendous amount from you MVP's, thank you.
On this one I am totally confused about the OpenArgs and have tried several variations of code I found on the web but nothing works.
I am trying to pass data in a field from Form1 to a field of the same name in an opening form2 which opens based on the user response in a MsgBox. I know I have to use the OpenArgs code but have had no luck so I am blatantly asking for code instructions instead of telling you what I have tried and asking for a correction.
The user enters data into the [Barcode] field of Form1 which searches for a match. If no match is found, the user is asked if they would like to create a new profile. If Yes, then Form2 opens in add mode - I want the value they searched on in Form1 ([Barcode]} to be passed to the [Barcode] field in Form2.
I really need both the code needed in Form1 that makes the data available to Form2 and the OnLoad OpenArgs code to pull the data into the [Barcode] field of Form2
Here is the code as it currently stands:
Option Explicit
Private Sub Command4_Click()
'Create var.
Dim intChk As Integer
'This line counts the number of rec instances in TBLLaptop.
intChk = DCount("*", "tblLaptop", "Barcode = '" & Forms!FRM_Search_To_Update_Encryption_Status!Barcode & "'")
'Does the rec exist? If not then open FRMCreateNewLaptopandUser_Encryption to add the new user details.
If intChk = 0 Then 'No?
Dim response As Long
response = MsgBox("This Laptop Does Not Exist, Do You Wish to Create Laptop Profile", vbYesNo + vbQuestion, "Create New Laptop Profile?")
Me.Barcode = Null
If response = vbYes Then DoCmd.OpenForm "FRMCreateNewLaptopandUser_Encryption", , , , acFormAdd
Else
DoCmd.RunMacro "MacroUpdateLaptopEncryption"
End If
End Sub
Thank you for your help!!
On this one I am totally confused about the OpenArgs and have tried several variations of code I found on the web but nothing works.
I am trying to pass data in a field from Form1 to a field of the same name in an opening form2 which opens based on the user response in a MsgBox. I know I have to use the OpenArgs code but have had no luck so I am blatantly asking for code instructions instead of telling you what I have tried and asking for a correction.
The user enters data into the [Barcode] field of Form1 which searches for a match. If no match is found, the user is asked if they would like to create a new profile. If Yes, then Form2 opens in add mode - I want the value they searched on in Form1 ([Barcode]} to be passed to the [Barcode] field in Form2.
I really need both the code needed in Form1 that makes the data available to Form2 and the OnLoad OpenArgs code to pull the data into the [Barcode] field of Form2
Here is the code as it currently stands:
Option Explicit
Private Sub Command4_Click()
'Create var.
Dim intChk As Integer
'This line counts the number of rec instances in TBLLaptop.
intChk = DCount("*", "tblLaptop", "Barcode = '" & Forms!FRM_Search_To_Update_Encryption_Status!Barcode & "'")
'Does the rec exist? If not then open FRMCreateNewLaptopandUser_Encryption to add the new user details.
If intChk = 0 Then 'No?
Dim response As Long
response = MsgBox("This Laptop Does Not Exist, Do You Wish to Create Laptop Profile", vbYesNo + vbQuestion, "Create New Laptop Profile?")
Me.Barcode = Null
If response = vbYes Then DoCmd.OpenForm "FRMCreateNewLaptopandUser_Encryption", , , , acFormAdd
Else
DoCmd.RunMacro "MacroUpdateLaptopEncryption"
End If
End Sub
Thank you for your help!!