Data Entry Form if Record Does Not Exist

MooTube

Registered User.
Local time
Yesterday, 23:53
Joined
Jul 2, 2015
Messages
31
Good Morning,


I was wondering if anyone could help me out with a small problem I am having. Currently I have a form that holds all information for each "Club". When a button on this form is clicked a pop-up form opens showing the "checklist" for each club, which is stored on a separate table but linked via "ClubID"

If I add a new club however, this link does not open the form in data entry mode, it gives an error then shows a blank pop-up box.

What I would like to do is to have the button open the form in data entry mode if the club does not have an associated record in the checklist table.

Code:
Private Sub Checklist_Click()


On Error GoTo AddNew
DoCmd.OpenForm "checkt", , , "[ClubID]=" & Me.OrgID
On Error GoTo AddNew
Exit Sub

AddNew:

Dim AddNew As DAO.Recordset
Set AddNew = CurrentDb.OpenRecordset("SELECT * FROM [dbo.checkt]")

AddNew.AddNew
AddNew![ClubID] = Me.OrgID
AddNew![OrgName] = Me.OrgName
AddNew.Update

MsgBox "Added To DB, Please click Checklist button again", , "Completed"



End Sub

so far I have got this, but it does not see an error until the other form is loaded, and when I add the "addnew" error part to the other form it still shows a blank pop-up form.

Any help would be greatly appreciated!
 
If you set the pop up form to be a sub form you won't have this issue, as the sub form "knows" you are on a new record.
If you have to have a pop up form then try using
Code:
If Me.NewRecord Then ....
On your button code.
 

Users who are viewing this thread

Back
Top Bottom