Link to home
Start Free TrialLog in
Avatar of rltomalin
rltomalinFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Open a form for a new record

I have a database that has tables for Clients and Jobs (tblClients and tblJobs)

Currently working is a form to add a new job.
This form has a query that joins tblClients and tblJobs
It is called from a button on a menu form using…
stDocName = "frmNewJob"
    DoCmd.OpenForm stDocName, , , stLinkCriteria
    DoCmd.GoToRecord , , acNewRec

On this form is a field cboClient.  The user selects the Client in this combo box and it populates the client details on the form.  The user then enters the new job information and saves to create the new job.
This is all working fine and has been for ages.

Now I want to do almost the same thing, but calling a copy of the above form – frmNewJobFromEditClient from the client details form.
So when the new form is opened I want it to open as a new record but with the Client details already populated (as if the user had selected the correct client).

I assumed that I would be able to put something like…
Me.cboClient = [frmEditClient].[Client ID]
in the Open event of the frmNewJobFromEditClient form.
I have tried all sorts of options of syntax without success.

Hope someone can help me out.

Regards
Richard
Avatar of Juan Ocasio
Juan Ocasio
Flag of United States of America image

I was just checking out some of the templates in Access and came across the Assets template (access 2016).  Take a look at it.  On the welcome page, it has a link to a video that shows how to use the template and it does something very similar.  It uses macros, but you can convert the macros to vba code.
Avatar of rltomalin

ASKER

Sorry, don't have Access 2016.  Currently using Access 2010.
ASKER CERTIFIED SOLUTION
Avatar of Dale Fye
Dale Fye
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Excellent response - thank you.  This was absolutely appropriate to my questions and easy to follow.
Had it working in 10 minutes.  I would never have figured this out myself.  I have done Access programming in the past but really only rarely - so need a nudge from time to time.
Regards
Richard
glad to help.  Don't forget to close out the question.