Group:  Microsoft Access ยป microsoft.public.access.formscoding
Thread: Auto Fill field - No answer yet

Geek News

Auto Fill field - No answer yet
Fahad 11/26/2008 10:28:04 PM
Hi

I'm using access 2007 and I have a form to enter the products info. the name
of the form is "frmProductInfo".

I have two fields that I want the 2nd field to be filled automatically if
the 1st field have certian value. the 2 fields are from different lookup
tables and no relation between the two tables. the tables are related with
the main table.

example:

1st field name: ProductFamily
2nd field name: ProductCat

if the 1st field value equal one of the following (value1 or value2 or
value3) then the 2nd field should have this value (value A)
if the 1st field value equal one of the following (value4 or value5 or
value6) then the 2nd field should have this value (value B)

1- could you please give me the code I should use to fill the 2nd field
automatically?
2- where should I put that code (i.e. on which field & Active should I put
it)? on 1st field on After Update action or on the 2nd field.

thanks...

Re: Auto Fill field - No answer yet
"Linq Adams via AccessMonster.com" <u28780[ at ]uwe> 11/27/2008 12:11:42 AM
Assuming that all "values" are text:

Private Sub ProductFamily_AfterUpdate()

Select Case Me.ProductFamily

Case "value1", "value2", "value3"
Me.ProductCat = "valueA"

Case "value4", "value5", "value6"
Me.ProductCat = "valueB"
Case Else
Me.ProductCat = ""

End Select

End Sub

--
There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000/2003

Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/Forums.aspx/access-formscoding/200811/1

Re: Auto Fill field - No answer yet
"Mike Painter" <mddotpainter[ at ]sbcglobal.net> 11/27/2008 2:49:30 AM
You have defined a relationship between them when you say that if one field
has a value x then other must have some value Y.
You should relate ProductFamily and ProductCat with a one to many and relate
the one side of that to your main table.


Fahad wrote:
[Quoted Text]
> Hi
>
> I'm using access 2007 and I have a form to enter the products info.
> the name of the form is "frmProductInfo".
>
> I have two fields that I want the 2nd field to be filled
> automatically if the 1st field have certian value. the 2 fields are
> from different lookup tables and no relation between the two tables.
> the tables are related with the main table.
>
> example:
>
> 1st field name: ProductFamily
> 2nd field name: ProductCat
>
> if the 1st field value equal one of the following (value1 or value2 or
> value3) then the 2nd field should have this value (value A)
> if the 1st field value equal one of the following (value4 or value5 or
> value6) then the 2nd field should have this value (value B)
>
> 1- could you please give me the code I should use to fill the 2nd
> field automatically?
> 2- where should I put that code (i.e. on which field & Active should
> I put it)? on 1st field on After Update action or on the 2nd field.
>
> thanks...


RE: Auto Fill field - No answer yet
Fahad 11/27/2008 10:49:01 PM
Dear Linq Adams & Mike

thank you very much for your help...

the code provided works fine.

many thanks

"Fahad" wrote:

[Quoted Text]
> Hi
>
> I'm using access 2007 and I have a form to enter the products info. the name
> of the form is "frmProductInfo".
>
> I have two fields that I want the 2nd field to be filled automatically if
> the 1st field have certian value. the 2 fields are from different lookup
> tables and no relation between the two tables. the tables are related with
> the main table.
>
> example:
>
> 1st field name: ProductFamily
> 2nd field name: ProductCat
>
> if the 1st field value equal one of the following (value1 or value2 or
> value3) then the 2nd field should have this value (value A)
> if the 1st field value equal one of the following (value4 or value5 or
> value6) then the 2nd field should have this value (value B)
>
> 1- could you please give me the code I should use to fill the 2nd field
> automatically?
> 2- where should I put that code (i.e. on which field & Active should I put
> it)? on 1st field on After Update action or on the 2nd field.
>
> thanks...
>

Home | Search | Terms | Imprint Contact
Newsgroups Reader - provided by WiredBox.Net