How to take values from an open Access continuous sub form, and "paste" them into another form?

168 views Asked by At

enter image description here

Okay. Let me try to explain what is happening here.

  1. User will select record in form 1 and click button.
  2. That will open form 2 to a detail form of that record.
  3. User will then select one or multiple codes from Form 2 and click order button.
  4. Form 3 will open with the info from Form 2, but I am having trouble getting the codes to fill in on Form 3. This is where I need help.

Existing code as follows:

    **Form 1 CODE**
Option Compare Database
Option Explicit

Private Sub RequeryForm()
    Dim SQL As String, WhereStr As String
    
    WhereStr = ""
    If Search <> "" Then
        If WhereStr <> "" Then WhereStr = WhereStr & " AND "
        WhereStr = "LocationID Like ""*" & AccountSearch & "*"""
    End If
    If NameSearch <> "" Then
        If WhereStr <> "" Then WhereStr = WhereStr & " AND "
        WhereStr = "FirstNameLastName Like ""*" & NameSearch & "*"""
    End If
    If CodeSearch <> "" Then
        If WhereStr <> "" Then WhereStr = WhereStr & " AND "
        WhereStr = "Code Like ""*" & CodeSearch & "*"""
    End If
    
    SQL = "Select * From AMSQuery"
    If WhereStr <> "" Then
        SQL = SQL & " Where " & WhereStr
    End If

    Me.RecordSource = SQL
End Sub
Private Sub ClearSearchBtn_Click()
    SetDefaults
    RequeryForm
End Sub


Private Sub OpenDetailbtn_Click()
    DoCmd.OpenForm "Form2", , , "LocationID=" & Me.LocationID
End Sub

Private Sub SearchBtn_Click()
    RequeryForm
End Sub

Private Sub SetDefaults()

    AccountSearch = Null
    NameSearch = Null
    CodeSearch = Null

End Sub


**Code For Form2**
Private Sub ExitBTN_Click()
    DoCmd.Close acForm, "Form2"
End Sub

Private Sub OrderILbtn_Click()
    DoCmd.OpenForm "RequestForm", acNormal, , , acFormAdd
    
End Sub

**Form 3 Code**
Option Compare Database
Option Explicit

'Private Sub IncNumber_BeforeUpdate(Cancel As Integer)
    'If Not (Me!IncNumber = "IncNumber" Or (Me!IncNumber <> 11) Or IsNull(Me!IncNumber)) Then
    'MsgBox "The Incident Number entered is less than 11 characters."
    'Cancel = True
    'End If
'End Sub


Private Sub CloseFormBtn_Click()
    DoCmd.Close acForm, "Form3", acSaveYes
    DoCmd.SelectObject acForm, "Form1"


End Sub
Private Sub Form_Load()
    
    Forms!RequestForm!Account = Forms!Form2!LocationID
    
End Sub

Private Sub SaveBtn_Click()

    If IsNull([Account]) Then
        MsgBox "You forgot to add a Y account.", vbOKOnly, "Missing Y account Warning!"
        Else
    DoCmd.RunCommand acCmdSaveRecord
    DoCmd.GoToRecord , , acNewRec
    End If
    'ILRequestID = "IL" & Right(Year([DateAndTimeRequested]), 2) & Format(Month([DateAndTimeRequested]), "00") & Format(Day([DateAndTimeRequested]), "00") & [EntryID]
    
    End Sub
0

There are 0 answers