Deverry
Registered User.
- Local time
- Tomorrow, 08:40
- Joined
- Aug 1, 2002
- Messages
- 10
I have 3 identical forms except for coding which basically perform the same task. One is for record entry, one for editing and one for finding individual records (ie filtering). These forms all have a check box and depending whether it is true or false specific instructions need to be performed. This is what is stuffing me up as I have little code knowledge. I would love to have just one form to perform all three options. I just don't know how to write my If/Else statements to incorporate all into one.
For the Add New I have:
Private Sub SP_LostFocus()
If Me.SP = True Then
DoCmd.GoToControl "Command78"
DoCmd.GoToControl "LE"
Else
DoCmd.GoToRecord acDataForm, "frmSponsors", acNewRec
DoCmd.GoToControl "Title"
End If
End Sub
Private Sub Gifts_AfterUpdate()
DoCmd.GoToControl "Command77"
DoCmd.GoToRecord acDataForm, "frmSponsors", acNewRec
DoCmd.GoToControl "Title"
End Sub
Private Sub Gifts_LostFocus()
DoCmd.GoToControl "Command77"
DoCmd.GoToRecord acDataForm, "frmSponsors", acNewRec
DoCmd.GoToControl "Title"
End Sub
For Edit Form I have:
Private Sub SP_LostFocus()
If Me.SP = True Then
DoCmd.GoToControl "Command78"
DoCmd.GoToControl "LE"
Else
DoCmd.GoToRecord acDataForm, "frmSponsorsEdit", acNext = 1
DoCmd.GoToControl "Title"
End If
End Sub
Private Sub Gifts_AfterUpdate()
DoCmd.GoToControl "Command77"
DoCmd.GoToRecord acDataForm, "frmSponsorsEdit", acNext = 1
DoCmd.GoToControl "Title"
End Sub
Private Sub Gifts_LostFocus()
DoCmd.GoToControl "Command77"
DoCmd.GoToRecord acDataForm, "frmSponsorsEdit", acNext = 1
DoCmd.GoToControl "Title"
End Sub
For filtered form I have
Private Sub SP_LostFocus()
If Me.SP = True Then
DoCmd.GoToControl "Command78"
DoCmd.GoToControl "LE"
Else
DoCmd.GoToControl "Command77"
DoCmd.GoToControl "Title"
End If
End Sub
Private Sub Gifts_AfterUpdate()
DoCmd.GoToControl "Command77"
DoCmd.GoToControl "Title"
End Sub
Private Sub Gifts_LostFocus()
DoCmd.GoToControl "Command77"
DoCmd.GoToControl "Title"
End Sub
I had originally placed the below code in the original form for a "delete" button as well.
Private Sub Form_Current()
If NewRecord = True Then
Me.DeleteRecord.Visible = False
Else:
Me.DeleteRecord.Visible = True
End If
End Sub
How do I re-write all the above so that only one form is necessary?
All help is appreciated.
Dev
For the Add New I have:
Private Sub SP_LostFocus()
If Me.SP = True Then
DoCmd.GoToControl "Command78"
DoCmd.GoToControl "LE"
Else
DoCmd.GoToRecord acDataForm, "frmSponsors", acNewRec
DoCmd.GoToControl "Title"
End If
End Sub
Private Sub Gifts_AfterUpdate()
DoCmd.GoToControl "Command77"
DoCmd.GoToRecord acDataForm, "frmSponsors", acNewRec
DoCmd.GoToControl "Title"
End Sub
Private Sub Gifts_LostFocus()
DoCmd.GoToControl "Command77"
DoCmd.GoToRecord acDataForm, "frmSponsors", acNewRec
DoCmd.GoToControl "Title"
End Sub
For Edit Form I have:
Private Sub SP_LostFocus()
If Me.SP = True Then
DoCmd.GoToControl "Command78"
DoCmd.GoToControl "LE"
Else
DoCmd.GoToRecord acDataForm, "frmSponsorsEdit", acNext = 1
DoCmd.GoToControl "Title"
End If
End Sub
Private Sub Gifts_AfterUpdate()
DoCmd.GoToControl "Command77"
DoCmd.GoToRecord acDataForm, "frmSponsorsEdit", acNext = 1
DoCmd.GoToControl "Title"
End Sub
Private Sub Gifts_LostFocus()
DoCmd.GoToControl "Command77"
DoCmd.GoToRecord acDataForm, "frmSponsorsEdit", acNext = 1
DoCmd.GoToControl "Title"
End Sub
For filtered form I have
Private Sub SP_LostFocus()
If Me.SP = True Then
DoCmd.GoToControl "Command78"
DoCmd.GoToControl "LE"
Else
DoCmd.GoToControl "Command77"
DoCmd.GoToControl "Title"
End If
End Sub
Private Sub Gifts_AfterUpdate()
DoCmd.GoToControl "Command77"
DoCmd.GoToControl "Title"
End Sub
Private Sub Gifts_LostFocus()
DoCmd.GoToControl "Command77"
DoCmd.GoToControl "Title"
End Sub
I had originally placed the below code in the original form for a "delete" button as well.
Private Sub Form_Current()
If NewRecord = True Then
Me.DeleteRecord.Visible = False
Else:
Me.DeleteRecord.Visible = True
End If
End Sub
How do I re-write all the above so that only one form is necessary?
All help is appreciated.
Dev