Can't create and populate new record

ezekiel

New member
Local time
Today, 10:51
Joined
Jan 4, 2011
Messages
1
I am having a difficult time creating and populating a new record in Access through a VBA built form. What is interesting to me about this is that the code I am using to create this record is used elsewhere in the application and works fine. But when used here, no immediate record is created. However, if I go to a different form in the application and create a record, the record is created AND the autonumber is updated PAST the point where the non-existent record would have been. For the life of me, I cannot figure out why this would be. Is the record somehow tied to the form (I sure haven't set anything like that)? I've searched high and low for any hint that might lead me to solving this issue and feel quite vexed.

Thank you for your time.

Code:
Private Sub save_Click()

    Dim curDatabase As Database
    Dim newSubMaster As DAO.Recordset
    
    Set curDatabase = CurrentDb()
    Set newSubMaster = curDatabase.OpenRecordset("subMaster")



    If Masters Then
        MyVal = Combo0.Value
        newSubMaster.AddNew
        
        newSubMaster("Master").Value = MyVal
        newSubMaster("Employee") = Me.Employee.Value
        newSubMaster("AssignDate").Value = Me.AssignDate.Value
        newSubMaster("Due Date").Value = Me.DueDate.Value
        newSubMaster("First Contact").Value = Me.FirstContact.Value
        newSubMaster("First Meeting").Value = Me.FirstMeeting.Value
        newSubMaster("Ext Date").Value = Me.ExtDate.Value
        newSubMaster("Delivery Date").Value = Me.DeliveryDate.Value
        newSubMaster("Directorate").Value = Me.Directorate.Value
        newSubMaster("Notes").Value = Me.Notes.Value
        Call MsgBox("Masters " & MyVal, vbOKOnly, "xXx")
    ElseIf SubMasters = True Then
    Else
        Call MsgBox("All False", vbOKOnly, "xXx")
    End If
    
    newSubMaster.Update
    Set newSubMaster = Nothing
    Set curDatabase = Nothing
End Sub
 
Might have something to do with your If then else statement. Is this msgbox popping up when it is run, otherwise your "If masters is not occuring.:

MsgBox("Masters " & MyVal, vbOKOnly, "xXx")
 

Users who are viewing this thread

Back
Top Bottom