Error 2147352567

Y

Yappy

I have a combo box on it that searches for the record on my form. My problem
is that when I enter a new record using my command button to add a new
record, then try to search for another record on my form using my combo box,
I get the following message:
Error 2147352567
Update or CancelUpdate without AddNew or Edit

I have the following code for my combo box:

Private Sub cmbCoName_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[VendorNumber] = '" & Me![cmbCoName] & "'"
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End Sub

This is what is highlighted in the code when I run the Debug:
Me.Bookmark = rs.Bookmark

When I close Access and reopen my database, only part of the new record I
entered is there.

How can I fix this? I am not good at VBA.

I am using Access 2003.

Thanks for your help.
 
A

Allen Browne

Try:

Private Sub cmbCoName_AfterUpdate()
' Find the record that matches the control.
Dim rs As DAO.Recordset
Dim strWhere As String

If Not IsNull(Me.cmbCoName) Then
If Me.Dirty Then Me.Dirty = False
Set rs = Me.Recordset.Clone
strWhere = "[VendorNumber] = """ & Me![cmbCoName] & """"
rs.FindFirst strWhere
If rs.NoMatch Then
MsgBox "Not found"
Else
Me.Bookmark = rs.Bookmark
End If
End If
End Sub

Explanation:
http://allenbrowne.com/ser-03.html

Note that if VendorNumber is a Number fields, you need to remove the extra
quotes.
 
Y

Yappy

Thanks, Allen. That seemed to help. I don't have any new records to add so
I won't know for sure until then.

Also, thanks for responding so quickly. I have seen other posts discussing
that this very helpful discussion site is going to be shut down by Microsoft.
I sure wish it wasn't true. This place has been very helpful to me. I will
be sad to see it go.

Allen Browne said:
Try:

Private Sub cmbCoName_AfterUpdate()
' Find the record that matches the control.
Dim rs As DAO.Recordset
Dim strWhere As String

If Not IsNull(Me.cmbCoName) Then
If Me.Dirty Then Me.Dirty = False
Set rs = Me.Recordset.Clone
strWhere = "[VendorNumber] = """ & Me![cmbCoName] & """"
rs.FindFirst strWhere
If rs.NoMatch Then
MsgBox "Not found"
Else
Me.Bookmark = rs.Bookmark
End If
End If
End Sub

Explanation:
http://allenbrowne.com/ser-03.html

Note that if VendorNumber is a Number fields, you need to remove the extra
quotes.

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.


Yappy said:
I have a combo box on it that searches for the record on my form. My
problem
is that when I enter a new record using my command button to add a new
record, then try to search for another record on my form using my combo
box,
I get the following message:
Error 2147352567
Update or CancelUpdate without AddNew or Edit

I have the following code for my combo box:

Private Sub cmbCoName_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[VendorNumber] = '" & Me![cmbCoName] & "'"
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End Sub

This is what is highlighted in the code when I run the Debug:
Me.Bookmark = rs.Bookmark

When I close Access and reopen my database, only part of the new record I
entered is there.

How can I fix this? I am not good at VBA.

I am using Access 2003.

Thanks for your help.

.
 

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