Auto fill

  • Thread starter Thread starter thom
  • Start date Start date
T

thom

I was asked this question - we have a field that is blank, if this field is
blank how can we get it to auto fill with the word "Active".

Thanks
 
??? Do you want to assign it a default value "Active" so users will overwrite
it if needed, or do you want it to insert "Active" in the field after the
form is filled in, or do you want to run an update query to change all blank
field values in the table to "Active"?
 
Thanks for your help, but I must be missing something.

I put the code in and still nothing.

here is what I have:

Private Sub txtReason_AfterUpdate()

If Nz(Me![txtReason], "") = "" Then
Me![txtReason] = "Active"

End If

End Sub

Am I missing something to easy here?

thom



glconsultants said:
thom,

In the AfterUpdate event of the relevant field use the following code:

if nz(me.[fieldname] , "") = "" then
me.[fieldname] = "Active"
end if

This will ill the field with 'Active' if the field is blank or null.

Regards,

Graham
G & L Consultants
MSCAS - ACCESS 2007
they want to insert "active" after the field is filled in.

thom
??? Do you want to assign it a default value "Active" so users will overwrite
it if needed, or do you want it to insert "Active" in the field after the
[quoted text clipped - 5 lines]
 
Thanks for your help, but I must be missing something.

I put the code in and still nothing.

here is what I have:

Private Sub txtReason_AfterUpdate()

If Nz(Me![txtReason], "") = "" Then
Me![txtReason] = "Active"

End If

End Sub

This code will fill in the txtReason textbox with the word "Active" if the
user updates it from some non-blank value to a blank.

I'm sure that's not your intent, but it's not quite clear what your intent is!

Under what circumstances do you want the textbox txtReason to be filled in
with the word "Active"?
 
Thanks for the reply,

this is the beginnings of a database to track patients in a medical study,
the idea was that in a box which listed the care, (discharge, unknown, death,
etc..) if this was blank, the text box would fill with the word "Acitve".
Still not doing what we need.

Not sure if we want to do this in a querey or on the form itself.

It is a Cbo box, sorry may fault there.

Thanks

John W. Vinson said:
Thanks for your help, but I must be missing something.

I put the code in and still nothing.

here is what I have:

Private Sub txtReason_AfterUpdate()

If Nz(Me![txtReason], "") = "" Then
Me![txtReason] = "Active"

End If

End Sub

This code will fill in the txtReason textbox with the word "Active" if the
user updates it from some non-blank value to a blank.

I'm sure that's not your intent, but it's not quite clear what your intent is!

Under what circumstances do you want the textbox txtReason to be filled in
with the word "Active"?
 
Thanks for the reply,

this is the beginnings of a database to track patients in a medical study,
the idea was that in a box which listed the care, (discharge, unknown, death,
etc..) if this was blank, the text box would fill with the word "Acitve".
Still not doing what we need.

Not sure if we want to do this in a querey or on the form itself.

It is a Cbo box, sorry may fault there.

Simply set its DefaultValue property to "Active" in that case.
 
Back
Top