BeardedSith
Member
- Local time
 - Yesterday, 22:09
 
- Joined
 - Feb 5, 2020
 
- Messages
 - 73
 
I have a form that serves as the central "hub" for my database.  It's called frmRewards.  Sometimes (when opening from Reports) I want the form to open to a specific record.  Other times, I want it to open to a new record.  The main issue lies within record navigation after I open the form using either of the following procedures.
frmRewards Form_Load():
	
	
	
		
Opening the form from another form, I'm using:
	
	
	
		
Opening the form from a report, to a specific record I'm using:
	
	
	
		
I can do one of two things, but I need both.
1) Open the form to a specific record
2) Navigate the form after it's opened using a listbox.
The issue is in order to get it to open to a specific record, it breaks the ability to navigate to other records on the form. This might be because "acFormAdd". I had to add this in because opening the form from another form always opened it to the first record in the database, instead of a "new" record. Effectively, sometimes I need OpenArgs, and sometimes I don't. Making one work breaks the other (report to specific record VS form to a new record).
 frmRewards Form_Load():
		Code:
	
	
	Private Sub Form_Load()
On Error GoTo Form_Load_Err
FilterList
Call FormStartUp: Call IssueRewards
    If (IsNull(OpenArgs)) Then
        'DoCmd.GoToRecord , "", acNewRec
        Exit Sub
    End If
Form_Load_Exit:
    Exit Sub
Form_Load_Err:
    MsgBox Error$
    Resume Form_Load_Exit
End Sub
	Opening the form from another form, I'm using:
		Code:
	
	
	Private Sub cmdCustomers_Click()
    DoCmd.Close acForm, "frmLanding", acSaveNo
    DoCmd.OpenForm "frmRewards", acNormal, , , acFormAdd
End Sub
	Opening the form from a report, to a specific record I'm using:
		Code:
	
	
	Private Sub txtID_Click()
On Error GoTo txtID_Click_Err
    If (IsNull(ID)) Then
        Beep
    End If
    
    If (Not IsNull(ID)) Then
        DoCmd.OpenForm "frmRewards", acNormal, "", "[ID]=" & ID, , acDialog
        On Error Resume Next
        DoCmd.Requery ""
    End If
txtID_Click_Exit:
    Exit Sub
txtID_Click_Err:
    MsgBox Error$
    Resume txtID_Click_Exit
End Sub
	I can do one of two things, but I need both.
1) Open the form to a specific record
2) Navigate the form after it's opened using a listbox.
The issue is in order to get it to open to a specific record, it breaks the ability to navigate to other records on the form. This might be because "acFormAdd". I had to add this in because opening the form from another form always opened it to the first record in the database, instead of a "new" record. Effectively, sometimes I need OpenArgs, and sometimes I don't. Making one work breaks the other (report to specific record VS form to a new record).