Updating and Clearing Recordsets

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi Folks! I've got a form with three search combos on it. Each doing a
record search on different criteria. They seem to be conflicting, in
someway. When a selection is made in one, you can't use another. I've also
noticed that when records are changed or created that the record sets in the
comboboxes aren't updated even after a requery. I had thought that the
solution was to clear the recordset after each search, but I'm having no
luck. Here a sample of the code I'm using in my combos:

Private Sub cboSrchbyOrder_AfterUpdate()
Dim rs As DAO.Recordset

If Not IsNull(Me.cboSrchbyOrder) Then
'Save before move.
If Me.Dirty Then
Me.Dirty = False
End If
'Search in the clone set.
Set rs = Me.RecordsetClone
rs.FindFirst "[Order Number] = '" & Me.cboSrchbyOrder & "'"
If rs.NoMatch Then
MsgBox "Not found: filtered?"
Else
'Display the found record in the form.
Me.Bookmark = rs.Bookmark
End If
Set rs = Nothing
End If
Me.cboSrchbyOrder = Null
End Sub

Originally, I had the wizard create this code for me. Then I tried Allen
Browne's method, but I get similar results. The error I get is:

Run-Time Error '2115':

The macro or function set to the BeforeUpdate or ValidationRule property for
this field is preventing Microsoft Office Access from saving the data in the
field.

It fails on this line:

Me.Dirty = False

Whenever I try to use more than one combobox or if I try to conduct more
than one search. Anybody have any ideas?
 
You probably have a field that's required (not null) and therefore need's to
be filled out (as you're not allowed to save the record)

hth

Pieter
 
Yes, I imagine so... However, none of the tables behind the form require
anything. I've checked several times. Could something about the design of
my form be causing the same thing?
--
Why are you asking me? I dont know what Im doing!

Jaybird


Pieter Wijnen said:
You probably have a field that's required (not null) and therefore need's to
be filled out (as you're not allowed to save the record)

hth

Pieter



Jaybird said:
Hi Folks! I've got a form with three search combos on it. Each doing a
record search on different criteria. They seem to be conflicting, in
someway. When a selection is made in one, you can't use another. I've
also
noticed that when records are changed or created that the record sets in
the
comboboxes aren't updated even after a requery. I had thought that the
solution was to clear the recordset after each search, but I'm having no
luck. Here a sample of the code I'm using in my combos:

Private Sub cboSrchbyOrder_AfterUpdate()
Dim rs As DAO.Recordset

If Not IsNull(Me.cboSrchbyOrder) Then
'Save before move.
If Me.Dirty Then
Me.Dirty = False
End If
'Search in the clone set.
Set rs = Me.RecordsetClone
rs.FindFirst "[Order Number] = '" & Me.cboSrchbyOrder & "'"
If rs.NoMatch Then
MsgBox "Not found: filtered?"
Else
'Display the found record in the form.
Me.Bookmark = rs.Bookmark
End If
Set rs = Nothing
End If
Me.cboSrchbyOrder = Null
End Sub

Originally, I had the wizard create this code for me. Then I tried Allen
Browne's method, but I get similar results. The error I get is:

Run-Time Error '2115':

The macro or function set to the BeforeUpdate or ValidationRule property
for
this field is preventing Microsoft Office Access from saving the data in
the
field.

It fails on this line:

Me.Dirty = False

Whenever I try to use more than one combobox or if I try to conduct more
than one search. Anybody have any ideas?
 
Ah. This question seems to have been answered for me. It looks like I was
trying to update INVNUM from the wrong subform and it was causing problems.
I am still trying to find a method that will allow me to undo the auto
population of INVNUM without causing problems with the lack of primary key.
I'm thinking that when you enter the textbox, Access expects a value to be
there even if you try to undo it. I guess its the difference between Null
and an empty string value.
--
Why are you asking me? I dont know what Im doing!

Jaybird


Jaybird said:
Yes, I imagine so... However, none of the tables behind the form require
anything. I've checked several times. Could something about the design of
my form be causing the same thing?
--
Why are you asking me? I dont know what Im doing!

Jaybird


Pieter Wijnen said:
You probably have a field that's required (not null) and therefore need's to
be filled out (as you're not allowed to save the record)

hth

Pieter



Jaybird said:
Hi Folks! I've got a form with three search combos on it. Each doing a
record search on different criteria. They seem to be conflicting, in
someway. When a selection is made in one, you can't use another. I've
also
noticed that when records are changed or created that the record sets in
the
comboboxes aren't updated even after a requery. I had thought that the
solution was to clear the recordset after each search, but I'm having no
luck. Here a sample of the code I'm using in my combos:

Private Sub cboSrchbyOrder_AfterUpdate()
Dim rs As DAO.Recordset

If Not IsNull(Me.cboSrchbyOrder) Then
'Save before move.
If Me.Dirty Then
Me.Dirty = False
End If
'Search in the clone set.
Set rs = Me.RecordsetClone
rs.FindFirst "[Order Number] = '" & Me.cboSrchbyOrder & "'"
If rs.NoMatch Then
MsgBox "Not found: filtered?"
Else
'Display the found record in the form.
Me.Bookmark = rs.Bookmark
End If
Set rs = Nothing
End If
Me.cboSrchbyOrder = Null
End Sub

Originally, I had the wizard create this code for me. Then I tried Allen
Browne's method, but I get similar results. The error I get is:

Run-Time Error '2115':

The macro or function set to the BeforeUpdate or ValidationRule property
for
this field is preventing Microsoft Office Access from saving the data in
the
field.

It fails on this line:

Me.Dirty = False

Whenever I try to use more than one combobox or if I try to conduct more
than one search. Anybody have any ideas?
 

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

Back
Top