Open form with data in field (1 Viewer)

NNothard

Registered User.
Local time
Today, 13:06
Joined
Jun 7, 2006
Messages
18
I have tried searching, but have not foud anything that quite fits the bill for this.

I would like to add some code to my event procedure for opening my form so that when it opens a field has a value entered in it and then the record is saved.
My form name is frmCompanyClients based on tblCompanyClients and the field is ClientType (text box)

I don't want to use a default value as I want to change what goes into that field depending on user input on the Front Form.

I need to save the record as soon as that is done so that a Client_ID number is generated and my subforms can then be properly associated via the Client_ID field. I was having problems with unassociated records, and found out that it was because I was entering data into the subforms first and not any of the parent form's fields and so because no Client_ID was generated I was getting the lost records.

Thanks
Nicolas
 

Krij

Registered User.
Local time
Today, 14:06
Joined
Jun 29, 2006
Messages
29
NNothard said:
I have tried searching, but have not foud anything that quite fits the bill for this.

I would like to add some code to my event procedure for opening my form so that when it opens a field has a value entered in it and then the record is saved.
My form name is frmCompanyClients based on tblCompanyClients and the field is ClientType (text box)

I don't want to use a default value as I want to change what goes into that field depending on user input on the Front Form.

I need to save the record as soon as that is done so that a Client_ID number is generated and my subforms can then be properly associated via the Client_ID field. I was having problems with unassociated records, and found out that it was because I was entering data into the subforms first and not any of the parent form's fields and so because no Client_ID was generated I was getting the lost records.

Thanks
Nicolas


Hi!

Are you opening the form from another form? With data already recorded? Then you should use the wizard to choose which form to open from a button on the first form. Then add more code to that button that will manipulate textbox on second form through:

Forms!frmSecondForm!ClientType.Text = Me!txtClientType.Text
or
Forms!frmSecondForm!ClientType.Text = "BusinessType"

Is Clent_ID the auotonumber of the first form. If so, access automatically saves when tabbing out of field. But you could do a save. (To find out how, look at the code when creating a save record button via the wizard). After the save is done you could open second form based on Client_ID in first form.

You could make the ClientType field a combobox, create a fieldlist (via the property sheet->data tab->rowsource etc).

But the default value thing is not so bad, considering the fact that you probably have more clienttypes of private, business or...?
 

Krij

Registered User.
Local time
Today, 14:06
Joined
Jun 29, 2006
Messages
29
NNothard said:
I have tried searching, but have not foud anything that quite fits the bill for this.

I would like to add some code to my event procedure for opening my form so that when it opens a field has a value entered in it and then the record is saved.
My form name is frmCompanyClients based on tblCompanyClients and the field is ClientType (text box)

I don't want to use a default value as I want to change what goes into that field depending on user input on the Front Form.

I need to save the record as soon as that is done so that a Client_ID number is generated and my subforms can then be properly associated via the Client_ID field. I was having problems with unassociated records, and found out that it was because I was entering data into the subforms first and not any of the parent form's fields and so because no Client_ID was generated I was getting the lost records.

Thanks
Nicolas


Hi!

Are you opening the form from another form? With data already recorded? Then you should use the wizard to choose which form to open from a button on the first form. Then add more code to that button that will manipulate textbox on second form through:

Forms!frmSecondForm!ClientType.Text = Me!txtClientType.Text
or
Forms!frmSecondForm!ClientType.Text = "BusinessType"

Is Clent_ID the auotonumber of the first form. If so, access automatically saves when tabbing out of field. But you could do a save. (To find out how, look at the code when creating a save record button via the wizard). After the save is done you could open second form based on Client_ID in first form.

You could make the ClientType field a combobox, create a fieldlist (via the property sheet->data tab->rowsource etc).

But the default value thing is not so bad, considering the fact that you probably have more clienttypes of private, business or...?
 

Krij

Registered User.
Local time
Today, 14:06
Joined
Jun 29, 2006
Messages
29
NNothard said:
I have tried searching, but have not foud anything that quite fits the bill for this.

I would like to add some code to my event procedure for opening my form so that when it opens a field has a value entered in it and then the record is saved.
My form name is frmCompanyClients based on tblCompanyClients and the field is ClientType (text box)

I don't want to use a default value as I want to change what goes into that field depending on user input on the Front Form.

I need to save the record as soon as that is done so that a Client_ID number is generated and my subforms can then be properly associated via the Client_ID field. I was having problems with unassociated records, and found out that it was because I was entering data into the subforms first and not any of the parent form's fields and so because no Client_ID was generated I was getting the lost records.

Thanks
Nicolas


Hi!

Are you opening the form from another form? With data already recorded? Then you should use the wizard to choose which form to open from a button on the first form. Then add more code to that button that will manipulate textbox on second form through:

Forms!frmSecondForm!ClientType.Text = Me!txtClientType.Text
or
Forms!frmSecondForm!ClientType.Text = "BusinessType"

Is Clent_ID the auotonumber of the first form. If so, access automatically saves when tabbing out of field. But you could do a save. (To find out how, look at the code when creating a save record button via the wizard). After the save is done you could open second form based on Client_ID in first form.

You could make the ClientType field a combobox, create a fieldlist (via the property sheet->data tab->rowsource etc).

But the default value thing is not so bad, considering the fact that you probably have more clienttypes of private, business or...?
 

NNothard

Registered User.
Local time
Today, 13:06
Joined
Jun 7, 2006
Messages
18
Thank you, I fiddled around and managed to get it working. I did not need explicitly save as you said

Cheers
 

Users who are viewing this thread

Top Bottom