 |
| Access VBA Discuss using VBA for Access programming. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

April 5th, 2004, 12:27 AM
|
|
Authorized User
|
|
Join Date: Apr 2004
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
add same data in diff table / search
Hi, I'm new learner of VBA, much appreciate you guys can give a big hands.
I have four tables with a same field "ID", how can i input data in table A, then it can be automatically update in other table b, c, d
Moreover, I want to add a search (find) function in a form, what is the script/procedure to call the record.
Thanks in advance.
|
|

April 5th, 2004, 10:45 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
|
|
Quote:
quote:Originally posted by yylee
I have four tables with a same field "ID", how can i input data in table A, then it can be automatically update in other table b, c, d
|
Close all tables, forms, etc. and just have the dB open. Click the "Relationships" button (or choose TOOLS > RELATIONSHIPS from the menu). In there, place the four tables. Click "ID" from your main table and drag it to "ID" in each table. When you do each, you'll get a dialog box. Make sure "Reinforce Referential Integrity" and "Cascade Update Related Fields" are CHECKED. Click CREATE. Save and exit the Relationships window.
From now on, if you edit the main table, the others will autoupdate.
Quote:
|
quote:Moreover, I want to add a search (find) function in a form, what is the script/procedure to call the record.
|
Make sure your wizards are turned on and place a combobox or a control button on your form. Let the Wizard's prompts ask you what you want and follow its instructions.
Welcome to P2P! :D
Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division
|
|

April 8th, 2004, 10:58 PM
|
|
Authorized User
|
|
Join Date: Apr 2004
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thanks, Greg ,it works.
Since the data is inputted in FORM view, I don't know why it can't be add or edit in FORM, the last record (=>*) is dimmed. How can i activate the button. Thanks in advance.
|
|

April 9th, 2004, 06:51 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
|
|
Quote:
quote:Originally posted by yylee
the last record (=>*) is dimmed. How can i activate the button.
|
In form design view, click the form and make sure that...
Allow Additions = Yes
Allow Deletions = Yes
Allow Edits = Yes
Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division
|
|

April 10th, 2004, 01:11 AM
|
|
Authorized User
|
|
Join Date: Apr 2004
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
They are already set YES. Any other method?
BTW, what means of bound / unbound form?
Thanks a lot!
|
|

April 10th, 2004, 07:54 PM
|
|
Friend of Wrox
|
|
Join Date: Oct 2003
Posts: 702
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Is your form based on a query (some times you can not edit those) or maybe you set the forms record source with the query builder (same thing, at times). By the way, Access comes with a find function, clik on the binoculars, this is the most useful method for searching.
Try not to code what has already been coded.
Sal
|
|

April 11th, 2004, 10:07 PM
|
|
Authorized User
|
|
Join Date: Apr 2004
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thanks Sal
I changed the form based on tables, so that they can edit.
Further to my first enquiry, one field in table C & D is related. How can I set one more relationship that these fields can be updated automatically. Much appreicate for your expertise advice.
|
|

April 12th, 2004, 10:01 PM
|
|
Friend of Wrox
|
|
Join Date: Oct 2003
Posts: 702
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Can the form edit now?
Sal
|
|

April 13th, 2004, 02:39 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 308
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
yylee -
To relate C & D, use the same method that Greg mentioned. Just drag the field from tableC to the field in tableD, and enforce integrity
Steven
I am a loud man with a very large hat. This means I am in charge
|
|
 |