English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I am wondering if this is possible.
If i enter in data within a form and i want certain parts of that data also copied into another form.
Can i make a button which allows me to do this?
Or even a macro?
If so, how...

Thanks~

2007-03-24 00:21:44 · 3 answers · asked by Gurpz 2 in Computers & Internet Programming & Design

3 answers

Yes, you can set the value of any form element via VBA and a button click element.

http://en.allexperts.com/q/Using-MS-Access-1440/Carrying-form-1.htm

Note to previous answerer: How does that blathering answer this very specific question, exactly? And why would anyone care one iota about anything you said in that inane missive?

2007-03-24 06:06:22 · answer #1 · answered by Anonymous · 0 0

Well, if you're absolutely sure that both forms will be open when the user clicks the button (an assumption I would prefer not to make), then you can make a command button (which I will call cmdUpdateOtherForm), and create an OnClick event procedure like the following:
(Note that the following code updates two fields in a second form. The second form is called, "OtherForm." The two textboxes are called Text1 and Text2. They are updated based on two textboxes in the current form, which are also called Text1 and Text2.

private sub cmdUpdateOtherForm_Click()
on error goto Err_cmdUpdateOtherForm_Click

Form_OtherForm.Text1.Value = Text1.Value
Form_OtherForm.Text2.Value = Text2.Value

Exit_cmdUpdateOtherForm_Click:
Exit sub

Err_cmdUpdateOtherForm_Click:
msgbox err.description,,err.number
resume exit_cmdUpdateOtherForm_Click
end sub

Note that if the second form is a subform of the first, then the code would be different (I don't remember how it goes off the top of my head, though).

However, instead of updating the other form (which you should probably only do in the case of subforms), you should think about updating the underlying tables directly. Let's say I have a form where I'm editing sessions for a client. The sessions are in one table (and that is the table that this form is bound to), and the client info is in another table, but the client has a DateModified field that you want to update whenever a session is updated. You can add the following code to the sessions form (either using a command button, or using the form's After_Update event):

Private Sub Form_AfterUpdate()
on error goto Err_Form_AfterUpdate

dim lClientID as long, sSQL as string

lClientID = ClientID.Value
sSQL = "UPDATE Clients SET DateModified = Now() WHERE ClientID = " & lClientID

docmd.setwarnings false
docmd.runsql sSQL
docmd.setwarnings true

Exit_Form_AfterUpdate:
Exit sub

Err_Form_AfterUpdate:
msgbox err.description,, err.number
resume Exit_Form_AfterUpdate

2007-03-24 16:32:06 · answer #2 · answered by Katie M 2 · 0 0

Yes you can add a button for MS Access data base . I hope you know MS Access as you can create many programs to use for needing to update a data base that will not get lost on your computer. A good friend of mine wrote his own access program to use for ebay so when he has items to sell he puts them into the data base and when they are sold he adds who bought them and the cost for everything. MS Access is a fantastic program. I use it for work to keep up with all of the emails and other items I send out so this way I have proof I sent the emails and received other things I asked for.

2007-03-24 12:12:18 · answer #3 · answered by cutiepie 3 · 0 1

fedest.com, questions and answers