You are here:

Visual Basic/MS Access VBA Copying values from Forn

Advertisement


Question
Here's my problem: I have the below code which copies the employee username from FormB and puts it in FrmEmployee when i click on a record in FormB (which is opened through a cmd button on FrmEmployee and lists all employees in the company and their shift pattern).

Private Sub Form_Click()
Forms!FrmEmployeee.Form.Username = Me.Username
End Sub

This works but it will only set the current username field to what is selected on FormB. FormB is in a datasheet view and will hold multiple values for the employee username. So what I want to do is expand the above code somehow so it takes me to the next record on FrmEmployee which means when i select another user from FormB this value will be copied into the next Username record, allowing me to build a list of employees.

Help require urgently

Thank you in advance

Answer
Hi Jay
If I understand your are asking, what you will need to do is have a similar line of code for each field in the Database.

So You would not only need
Forms!FrmEmployeee.Form.Username = Me.Username

But
Forms!FrmEmployeee.Form.Department = Me.Department
Forms!FrmEmployeee.Form.Office = Me.Office
Forms!FrmEmployeee.Form.Email= Me.Email
Etc.
Etc. . .

If this is not what you are asking please ask a follow up question with more details.

Visual Basic

All Answers


Answers by Expert:


Ask Experts

Volunteer


Kevin Watkins

Expertise

I have written several programs integrating with MS Office including Access, Excel, and Word. I have used control arrays as well as data arrays, text files. I have an associates degree in programming. Please do not ask questions about VBA or dot net. I can only answer questions about Visual Basic 6.

Experience

I have written several programs integrating with MS Office including Access, Excel, and Word. I have used control arrays as well as data arrays, text files. I have an associates degree in programming.

Education/Credentials
I have an associates degree in computer programming.

©2016 About.com. All rights reserved.