Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

auto add value to field when form opens

Status
Not open for further replies.

tonyx666

MIS
Apr 13, 2006
214
GB
a simple request i think..

when my form opens, i would like to add a value to a field automatically..


lets say my field is called 'field1' and the value is 'value1'

i presume it will be some kind of open form event or something..

how would i code that?

London Heathrow Cars
 
You need to tell us a little more about what you're trying to do. Single record or continuous form. Is this a value assigned to a field on one record or all records?

Generically, assigning a value to a field when the form opens would be something like this:

Code:
Private Sub Form_Load()
    YourFieldName.Value = DesiredValue
End Sub

DesiredValue as is for a number data type or
"DesiredValue" for a string data type.

ive us some more details.

The Missinglinq

There's ALWAYS more than one way to skin a cat!
 
i see.. well basically this database is for a cab office..

there is one main table - bookings.

there are generally 3 types of booking, cash, account, and credit card

so i have created 3 forms, each one with the relevant fields displayed..

i just wanted the 'jobtype' field to be populated with a value when it was opened..

so when the cash form is opened, the jobtype is set to CASH.. etc..

what i have done now is just right clicked the text box for that field, and put a default value of what i wanted there.. and when the form opens, that has the value in it.

i think that has done the trick

London Heathrow Cars
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top