add record to another form

G

Guest

Hi
I have a command button which opens a form(returns) I would like to copy 2
fields in active record to next record in returns form (works order and fg
code)
I am use to writing in vb but not vba
please give example code if possible
Thanks
tina
 
G

Guest

Declaring a variable to be used to transfer the value between the current &
new records

In declarations section of the form's module:
Private worksOrderTemp as String (or whatever type you need)
Private fgCodeTemp as String

Add these two lines on click of button that takes you to new record.

ButtonNew_Click()
worksOrderTemp = worksOrder '(use actual name of your works order control)
fgCodeTemp = fgCode

Add this to Form_Current

Form_Current()
If Form.NewRecord then 'do not change the fields on old records
worksOrder = worksOrderTemp
fgCode = fgCodeTemp
Else ' get value from existing record if it is not being changed
worksOrderTemp = worksOrder
fgCodeTemp = fgCode
End If

You may want to accomodate the possibility of going to a new record
immediately upon opening the form (in which case both variables would be
null).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top