I currently have a tab structure for a simple DB, and after a little bit of fiddling I've managed to get two of the tabs to link up in the way I want.
For example, the Main.ID is taken from Table 1 and then when Page2 (of the tab) is opened it passes the Main.ID into the Sub.ID field, allowing me to keep track of who has what.
The Problem I now seemed to have created, is that when I move from Page 1 to Page 2, it's automatically creating a new record in the table for Page 2, even if no data has been entered (it didn't do this originally).
I've tried to create a simple msgbox to try and stop this from happening, but it I have it run on Page 2 the record get's created, if I run it on Page 1, the record doen't get created but the msgbox appears twice, because of how it's set.
This is my current code:
Is there a way that I can set it so that either the message box works on Page 2 without committing a record, or to get it to either not save, or delete the blank record.
Thanks
For example, the Main.ID is taken from Table 1 and then when Page2 (of the tab) is opened it passes the Main.ID into the Sub.ID field, allowing me to keep track of who has what.
The Problem I now seemed to have created, is that when I move from Page 1 to Page 2, it's automatically creating a new record in the table for Page 2, even if no data has been entered (it didn't do this originally).
I've tried to create a simple msgbox to try and stop this from happening, but it I have it run on Page 2 the record get's created, if I run it on Page 1, the record doen't get created but the msgbox appears twice, because of how it's set.
This is my current code:
Code:
Private Sub TabCtl0_Change()
Dim Name As String
Dim Val As String
If Me!TabCtl0 = 1 Then Form_Subfrm_Worker_Details_Entry.Form.Requery
Subfrm_Lap_Entry!Laptop_ID.SetFocus
If Subfrm_Lap_Entry!Laptop_ID.Text = "" Then
Val = MsgBox("There is no corresponding Person Details! Please Create a Worker First?", vbOKOnly)
Me.TabCtl0.Pages.Item(1).SetFocus
End If
If Me!TabCtl0 = 2 Then
Form_Subfrm_Lap_Entry.Form.Requery
Subfrm_Lap_Entry!Laptop_ID = Form_Subfrm_Worker_Details_Entry![tblWorkers.ID]
Name = Form_Subfrm_Worker_Details_Entry![tblWorkers.Forename] & " " & Form_Subfrm_Worker_Details_Entry![tblWorkers.Surname]
Subfrm_Lap_Entry!txtName.SetFocus
Subfrm_Lap_Entry!txtName.Text = Name
End If
End Sub
Is there a way that I can set it so that either the message box works on Page 2 without committing a record, or to get it to either not save, or delete the blank record.
Thanks