list box open form new Record with the ID in (1 Viewer)

Fugan

Registered User.
Local time
Today, 23:48
Joined
Aug 7, 2006
Messages
16
Hello everyone,
i have 2 tables,
table one =client detials
table two = job information
both have field called ClientNumber in them and have Relationships

i have a form with list box in it with ClientNumber(hidden), Surname, First name and i have a button and i want when i choose a name of list box and click button to open a job information form and be on new record and i want the ClientNumber to be put in the ClientNumber textbox on the form

so if u click on eg: David scown and click button want it to open form and be on a new record and put his Client Number in the client number text box
 
Last edited:

Junkee Brewster

Registered User.
Local time
Today, 23:18
Joined
May 21, 2005
Messages
33
Click on the List Box in design view. Events Tab>OnClick or On Dbl Click and open a new Sub.

Use:
Code:
DoCmd.OpenForm "YOUR FORM TO OPEN (NAME)", , , "[ClientNumber] = " & Me.YOURLISTBOXNAME, , acWindowNormal

Make sure to put in the form to open name, and your listbox name.

I personally use double click, because that way the user/you are obviously wanting to open the form, and not clicking once by mistake.

HTH - Junkee :)
 

Junkee Brewster

Registered User.
Local time
Today, 23:18
Joined
May 21, 2005
Messages
33
Well I'm off the boil tonight.. I see you want to open to DATAENTRY mode.

Still use the code I gave for your command button, but what you will need to do:

On the form you want to have as the data entry form, make table client details as the form record, and add a text box with Client Number FROM your main table. Set the Client Number Visible>NO

Then, make your data entry form like you want it on a seperate form, and place it on the MAIN form that will be opened from the listbox - i.e as a subform, making sure ClientNumber is your linked relationship.

THIS way, when you start to type your new record, the number should update as matching table Client Details on your parent data entry form, which, if using the code, should open to the same number as the list box! Make sense?
 

Fugan

Registered User.
Local time
Today, 23:48
Joined
Aug 7, 2006
Messages
16
i wanted it to click on one of clients name from list box and click button to open form "job information on a new record and put the client number in the text box on the new record on form
i can't realy make it so i just click on names and it opens form because i have other button on form other forms using list box
 

Fugan

Registered User.
Local time
Today, 23:48
Joined
Aug 7, 2006
Messages
16
Junkee Brewster,
ty for trying to help but i find out how i can do it i just was playing around and got it to work
first i made marco to open form and go to new record and then tryed to make it put the client number in after it want to new record
i used this code to make it do it

code:

Dim stDocName As String
strclientnumber = Surnameclients
stDocName = "mcr new job information"
DoCmd.RunMacro stDocName
Forms!frmjobinformation!Clientnumber = strclientnumber

and made module and put
code:

Public strclientnumber As String


________________________
david
 
Last edited:

Users who are viewing this thread

Top Bottom