Setting a value after insert?

  • Thread starter Maury Markowitz
  • 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
 
L

Lynn Trapp

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
 
M

Maury Markowitz

Do you requery the form after you do the insert?

Sadly it's not that easy, the record will fail to meet the criterion
unless that field gets set.
 
M

Maury Markowitz

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
 
J

JString

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

John W. Vinson

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.
 
M

Maury Markowitz

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
 
M

Maury Markowitz

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
 
J

John W. Vinson

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.
 
M

Maury Markowitz

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
 
J

JString

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.
 

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