Record not inserting

M

Mark A. Sam

Hello,

In the procedure below, there is an edit and an addnew method. The edit
method works fine, and the addnew method gets addressed, but new records are
not created. They don't show up in the table.

Thanks for any help and God Bless,

Mark A. Sam


Private Sub Form_AfterDelConfirm(Status As Integer)
On Error Resume Next
Dim i As Integer
Dim cnt As Integer
With Me.RecordsetClone
.MoveLast
Do Until .BOF
cnt = DCount("[drop]", "LoadSheetsST", "[LSID] = " & [LSID] & " And [Drop]
= " & ![Drop]) 'Allows using same number for multiple records
i = i + 1
If ![KeepDropNumber] = True Then
i = ![Drop] '+ 1
Else
.Edit
![Drop] = i
.Update
End If

.MovePrevious
Loop

'Check for missing Drops in and insert them
Dim iMin As Integer
Dim iMax As Integer
iMin = Nz(DMin("[drop]", "LoadSheetsST", "[LSID] = " & [LSID]), 0)
iMax = Nz(DMax("[drop]", "LoadSheetsST", "[LSID] = " & [LSID]), 0)
For i = iMin To iMax
If DCount("[drop]", "LoadSheetsST", "[LSID] = " & [LSID] & " And [Drop]
= " & i) = 0 Then 'This drop needs to be created
.AddNew
![Drop] = i
.Update
End If
Next i

.Requery

End With
 
G

Guest

Looks like drop is the only field that is being added. You will want to look
at the table that you are adding to and see if there is a primary key that
needs to also be filled in for the new record. A second thing to check would
be whether your database has data integrity on it and may not allow you to
add a record to one table unless something that it matches is in another
table.

Please let me know if I can provide more assistance.
 
M

Mark A. Sam

Thank you. I hate to use a cliche, but, "duuuuuh me". I simply forgot to
populate the child link field. Your second suggestion was on target.

God Bless,

Mark


hmadyson said:
Looks like drop is the only field that is being added. You will want to
look
at the table that you are adding to and see if there is a primary key that
needs to also be filled in for the new record. A second thing to check
would
be whether your database has data integrity on it and may not allow you to
add a record to one table unless something that it matches is in another
table.

Please let me know if I can provide more assistance.

Mark A. Sam said:
Hello,

In the procedure below, there is an edit and an addnew method. The edit
method works fine, and the addnew method gets addressed, but new records
are
not created. They don't show up in the table.

Thanks for any help and God Bless,

Mark A. Sam


Private Sub Form_AfterDelConfirm(Status As Integer)
On Error Resume Next
Dim i As Integer
Dim cnt As Integer
With Me.RecordsetClone
.MoveLast
Do Until .BOF
cnt = DCount("[drop]", "LoadSheetsST", "[LSID] = " & [LSID] & " And
[Drop]
= " & ![Drop]) 'Allows using same number for multiple records
i = i + 1
If ![KeepDropNumber] = True Then
i = ![Drop] '+ 1
Else
.Edit
![Drop] = i
.Update
End If

.MovePrevious
Loop

'Check for missing Drops in and insert them
Dim iMin As Integer
Dim iMax As Integer
iMin = Nz(DMin("[drop]", "LoadSheetsST", "[LSID] = " & [LSID]), 0)
iMax = Nz(DMax("[drop]", "LoadSheetsST", "[LSID] = " & [LSID]), 0)
For i = iMin To iMax
If DCount("[drop]", "LoadSheetsST", "[LSID] = " & [LSID] & " And
[Drop]
= " & i) = 0 Then 'This drop needs to be created
.AddNew
![Drop] = i
.Update
End If
Next i

.Requery

End With
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top