Setting a value after insert?

  • Thread starter Thread starter Maury Markowitz
  • Start date Start date
M

Maury Markowitz

I have a form that uses a filter to show about 25 records of 2000 in
the base table. There is no default value on the filter column, so
when you add a row, it disappears because it does not meet the
criterion.

So basically I need to set the value of the filter column when they
insert a record. I tried using BeforeInsert and AfterInsert, but they
don't seem to get called when I would expect. What's the basic
solution to this problem?

Maury
 
I have a form that uses a filter to show about 25 records of 2000 in
the base table. There is no default value on the filter column, so
when you add a row, it disappears because it does not meet the
criterion.

So basically I need to set the value of the filter column when they
insert a record. I tried using BeforeInsert and AfterInsert, but they
don't seem to get called when I would expect. What's the basic
solution to this problem?

Maury

Do you requery the form after you do the insert?
Lynn Trapp
www.ltcomputerdesigns.com
 
Can you post the code that you are trying to work with?

Sure:

Private Sub Form_AfterInsert()
Me!clientType = "Our Funds"
End Sub

I've also tried BeforeInsert, and Before/AfterUpdate.

Maury
 
That's odd. are you using any vba procedures to force filters? If so can
you post that code?
 
Sure:

Private Sub Form_AfterInsert()
Me!clientType = "Our Funds"
End Sub

I've also tried BeforeInsert, and Before/AfterUpdate.

Maury

BeforeInsert should work - the record has already been saved to disk in
AfterInsert - but if it's just a constant value, why not simply set the
Default Value property (either on the field in the table, or on the control in
the Form)? You could set the default value in the Form's Open event, if it's
variable from session to session.
 
BeforeInsert should work - the record has already been saved to disk in
AfterInsert

Which is fine, but neither of these events is firing. They are events
on the form, that's where they should be, right?
- but if it's just a constant value, why not simply set the

It's only a constant in this one form. Other forms scrape the table
other ways.

Maury
 
That's odd.  are you using any vba procedures to force filters?  If so can
you post that code?

No, which is funny because I do just that in a lot of other forms!

Maury
 
Which is fine, but neither of these events is firing. They are events
on the form, that's where they should be, right?

If you're inserting a record (navigating to the "new record" and dirtying it
by user entry, not by code) then both events should fire. If they're not,
something's wrong!
It's only a constant in this one form. Other forms scrape the table
other ways.

So? A textbox on a form has a DefaultValue property; you don't need to use the
Table Field's DefaultValue.
 
So? A textbox on a form has a DefaultValue property; you don't need to use the
Table Field's DefaultValue.

Oh, I see what you mean. The field doesn't appear on the form, but I
guess there's no reason for that. I'll add one and hide it.

Maury
 
I don't know.... I wish I could help you but I tested the issue as you
described it and it works out fine for me. You could probably check to see
if something is stopping your vba code, like macro security.
 
Back
Top