In
Chrism said:
That was what I was thinking, but tried working around it so many
ways. It probably is something so easy that I totally overlooked.
Here is the code for the button. Again thanks for the help!!!
Dim rstmanuf As ADODB.Recordset
If IsNull(Me.manuf) Then
MsgBox "Enter a Manuf"
Else
Set rstmanuf = New ADODB.Recordset
With rstmanuf
.ActiveConnection = CurrentProject.Connection
.CursorType = adOpenKeyset
.LockType = adLockOptimistic
.Open "tblmanuf"
.AddNew
!Manufacturer = Me.manuf
.Update
End With
End If
rstmanuf.Close
Set rstmanuf = Nothing
Me.manuf = Null
Me.manuf.SetFocus
DoCmd.Close
DoCmd.OpenDataAccessPage "frmmisc"
End Sub
Is that form bound? If it is, and any of the bound controls -- such as
[manuf], maybe -- have been modified, then setting the control to Null
isn't going to stop the form from saving the record when you close it.
Why are you adding the record via a recordset, rather than letting the
form save it?
Assuming I'm right, and the form is bound to tblmanuf, then you need to
take either of two approaches:
1. Don't use a bound form. Then you can use the recordset as you're
doing, to add the record to the table (though it seems like a laborious
way to do it).
2. Use a bound form, as you have it, and don't bother with the
recordset. Just force the form to save the current record before
opening your data access page:
Me.Dirty = False
DoCmd.OpenDataAccessPage "frmmisc"
DoCmd.Close acForm, Me.Name, acSaveNo
There's a third alternative, which is to leave everything pretty much as
it is, but *undo* the bound form before closing it -- instead of
"Me.manuf = Null", write "Me.Undo". However, I don't see the point of
using a bound form *and* a recordset to update the same table.