Hello.
I'm totaly newbie in access coding. I've created my first DB, two tables and a form.
Tables are:
tbl_product
product|amount
pr1|100
pr2|200
pr3|250
etc...
tbl_subproducts
subproduct|amount|add|product
sub1|100|no| |
sub2|250|yes|pr3|
frm_subproducts is used for filling values. Main idea, that we fill only name of subproduct and amount of it (row 1), but in some cases it can be added to product and it's amount will be actually the same, as amount of product from tbl_product (row 2).
On my form, "subproduct" and "amount" are textboxes, "add" is checkbox and "product" is combobox (dropdown list). By default, "product" is disabled. I need to know, how can i:
1. When "add" checked - disable "amount" and enable "product".
2. When some value choosed in "product", for example pr2, amount of 200 (we'll take it from tbl_products) is filled in "amount".
I've googled and found this for step 2, but i've no idea, where should i use this code...
Thank's in advance.
I'm totaly newbie in access coding. I've created my first DB, two tables and a form.
Tables are:
tbl_product
product|amount
pr1|100
pr2|200
pr3|250
etc...
tbl_subproducts
subproduct|amount|add|product
sub1|100|no| |
sub2|250|yes|pr3|
frm_subproducts is used for filling values. Main idea, that we fill only name of subproduct and amount of it (row 1), but in some cases it can be added to product and it's amount will be actually the same, as amount of product from tbl_product (row 2).
On my form, "subproduct" and "amount" are textboxes, "add" is checkbox and "product" is combobox (dropdown list). By default, "product" is disabled. I need to know, how can i:
1. When "add" checked - disable "amount" and enable "product".
2. When some value choosed in "product", for example pr2, amount of 200 (we'll take it from tbl_products) is filled in "amount".
I've googled and found this for step 2, but i've no idea, where should i use this code...
Code:
'************* Code Start **************
' This code was originally written by Erika Yoxall.
' It is not to be altered or distributed,
' except as part of an application.
' You are free to use it in any application,
' provided the copyright notice is left unchanged.
'
' Code Courtesy of
' Erika Yoxall
'
Sub Zip_OnExit(Cancel As Integer)
Dim varState, varCity As Variant
varState = DLookup("State", "tblZipCode", "ZipCode =[Zip] ")
varCity = DLookup("City", "tblZipCode", "ZipCode =[Zip] ")
If (Not IsNull(varState)) Then Me![State] = varState
If (Not IsNull(varCity)) Then Me![City] = varCity
End Sub
'************* Code End **************