Auto fill

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
 
M

Maarkr

??? 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"?
 
T

thom

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]
 
J

John W. Vinson

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"?
 
T

thom

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"?
 
J

John W. Vinson

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.
 

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