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

glconsultants

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]
 
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.
 
G

glconsultants via AccessMonster.com

If you want the 'Active' to appear on a new record as a default unless
changed by the user then you need to

1/ Make sure that Active is an available item in your combo box.
2/ Set your 'Default Value' in the property sheet, Data tab for the combo
box to "Active"

If you use limit to list then no one would be able to enter a blank value
(unless you have a blank value on your list of course).

For existing records you may want to write an 'Update Query' that changes the
value of this field to 'Active' if its current contents are null or blank.

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
[quoted text clipped - 18 lines]
Under what circumstances do you want the textbox txtReason to be filled in
with the word "Active"?
 

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