Want One Form to do everything

Deverry

Registered User.
Local time
Tomorrow, 00:49
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 searching I would use a proper search form - (there are many examples posted, see "Quicksearch" in sample Db's) then you could doubleclick on the result listbox and open the form to the selected record which can then be edited.

Then have an "Add New Record" button on the form to clear fields to input a new record. Stick a delete button on as well from the form wizard.

Col
 
Hi Pat,

I know that my form is clumsy. The reason is that I do not want three fields to be seen unless/until the checkbox is true in which case data then needs to be entered. My tab order is working fine, the form appears as a full page dialog box and I am keeping the two views clean of each other. Before I placed the transparent controls precisely going from last to first cut off the top. Would love to know a better way to do this. A separate pop-up form (original idea) gave me record synchronisation issues.

Thanks
Dev
 
Thanks, works perfectly after I redesigned the form to fit on one screenview.
I also saw where I went wrong when I originally tried to use the visible control. Database now ready to be handed over thanks to you.

Lukim yu somepla tru

Dev
 

Users who are viewing this thread

Back
Top Bottom