So I defined a variable within the "On Load" for a new form when it loads, basically it grabs it from the OpenArgs when the main form calls to load the second form (only way I could get it to pass the ID I needed). But I need to use that ID number for once a button is clicked but it appears that variable can't be used outside the on load event now i believe? Here is what I have (sorry it's a bit messy, Ive been messing with it all day.)
Code:
Option Compare Database
Private Sub btnUpdate_Click()
'Check to see if all fields are filled in, avoiding Null entries
'If IsNull(txtNotes) Or IsNull(boxFixed) Then
' MsgBox "Please ensure all fields are filled in!", , "Incomplete!"
' Me.Undo
' Else
'No Null were found, insert into table and exit after requery
' CurrentDb.Execute ("UPDATE Table1 SET [Resolved By] = '" & boxFixed & "' WHERE [ID] = '" & intID & "'")
' MsgBox "New repair request ticket added."
' [Forms]![Main1]![lstActive].Requery
' DoCmd.Close
'End If
lblTest.Caption = intID
End Sub
Private Sub cmdClose_Click()
[Forms]![Main1]![lstActive].Requery
DoCmd.Close
End Sub
Private Sub Form_Load()
Dim intID As Integer
Dim strTitle
Dim strRequested
Dim strAssigned
Dim strPriority
Dim strStatus
Dim strComments
Dim strDate
'Test the OpenArgs to ensure it isn't 0
If Me.OpenArgs > 0 Then
intID = Me.OpenArgs
'Lookup information of obtained selection row from lstActive (Main1)
strTitle = DLookup("[Title]", "Table1", "[ID]=" & intID)
strRequested = DLookup("[Requested By]", "Table1", "[ID]=" & intID)
strAssigned = DLookup("[Assigned To]", "Table1", "[ID]=" & intID)
strPriority = DLookup("[Priority]", "Table1", "[ID]=" & intID)
strStatus = DLookup("[Status]", "Table1", "[ID]=" & intID)
strComments = DLookup("[Comments]", "Table1", "[ID]=" & intID)
strDate = DLookup("[Submitted]", "Table1", "[ID]=" & intID)
'Fill labels on Edit form
lblTitle.Caption = strTitle
lblRequested.Caption = strRequested
lblAssigned.Caption = strAssigned
lblPriority.Caption = strPriority
boxStatus.Value = strStatus
lblDate.Caption = strDate
lblComments.Caption = strComments
End If
End Sub
This right here is what I using to test to see if the value was actually getting passed or not. The number DOES work coming on the on_load and allowing to pull the proper record. It just won't let me use it in the btnUpdate_Click().
Code:
lblTest.caption = intID