Opening a new form from another form

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

i have a form(form1) which i use to enter a name into and then press enter
which opens up another form(form2) ,this bit i can do, but i cant seem to
find out how to get any information(address and Contact details etc) relating
to the name i enter out of the table(table1) and into the text boxes on form2.
i dont want to use command buttons or list boxes as i have to many names in
the table and i would rather use the keyboard for this operation than the
mouse.
 
Gazza said:
i have a form(form1) which i use to enter a name into and then press enter
which opens up another form(form2) ,this bit i can do, but i cant seem to
find out how to get any information(address and Contact details etc) relating
to the name i enter out of the table(table1) and into the text boxes on form2.
i dont want to use command buttons or list boxes as i have to many names in
the table and i would rather use the keyboard for this operation than the
mouse.


You can achieve that effect by binding form2 to the
contacts table and adding the appropriate controls to view
the data. If you open the form from the database window, it
should allow you to navigate through all the contacts.

Now use the form1 text box's AfterUpdate event to open form2
using a line of code like:

DoCmd.OpenForm "form2",,,"namefield=""" thetextbox & """"
 
i got this to sort of work but not quite properly.
when i enter a name into the text box on form1, before it opens form to a
small box opens up with"Enter Parameter Value" in the top bar and the name i
just typed above the text box so i have to enter the name again and it then
opens up form2 with the details entered as i wanted.
I was wondering if ther is a way to get the "enter parameter value"box not
to open and just go straight to form2.
Thanks for the help
 
You skipped the step about opening the form from the
database window.

Just remove the criteria from the form's record source
query.
 
The forms record source is a table and not a query.
Does this mean i have to create a query for this to work, if so does the
query have to be the record source for both formsor just form1.

Marshall Barton said:
You skipped the step about opening the form from the
database window.

Just remove the criteria from the form's record source
query.
--
Marsh
MVP [MS Access]

i got this to sort of work but not quite properly.
when i enter a name into the text box on form1, before it opens form to a
small box opens up with"Enter Parameter Value" in the top bar and the name i
just typed above the text box so i have to enter the name again and it then
opens up form2 with the details entered as i wanted.
I was wondering if ther is a way to get the "enter parameter value"box not
to open and just go straight to form2.
 
Using a table is fine, but where else but a record source
query can a parameter prompt come from in a form? Dig
around in form2 and look for a query in a combo box or
somewhere the contains the prompt string in the popup box.
Are you sure Form2's record source is a table???
 
ok sorry to be a pain but this is really starting to annoy me now.

The forms i have are :- Supplier Select (Form1)
Supplier Enquiry (Form2)

Form1 Recordsource is Supplier Details Table
Form2 RecordSource is Supplier Details Table

The idea is to type a supplier name into the supplier name text box on form1
and it will open form2 with all the text boxes filled with the details from
the supplier details table.

in the Afterupdateof form1 the code is :-

Docmd.openform "Supplier Enquiry",,,"supplier name=" & me.Supplier_name

i am obviously going wrong somewhere so any help would be appriciated

Marshall Barton said:
Using a table is fine, but where else but a record source
query can a parameter prompt come from in a form? Dig
around in form2 and look for a query in a combo box or
somewhere the contains the prompt string in the popup box.
Are you sure Form2's record source is a table???
--
Marsh
MVP [MS Access]


The forms record source is a table and not a query.
Does this mean i have to create a query for this to work, if so does the
query have to be the record source for both formsor just form1.
 
Ah ha! That's it. The supplier name is a text string so it
must be enclosed in quotes:

Docmd.openform "Supplier Enquiry",,, _
"supplier name=""" & me.Supplier_name & """"

The reason for what appears to be so many quotes is that you
have to use two quotes to represent one quote when it is
inside another set of quotes.
 
I entered the line into textbox1 of Form1 afterupdate and when i press enter
i now get runtime error 3075 - syntax error(missing operator) in query
expression `supplier name =`


Marshall Barton said:
Ah ha! That's it. The supplier name is a text string so it
must be enclosed in quotes:

Docmd.openform "Supplier Enquiry",,, _
"supplier name=""" & me.Supplier_name & """"

The reason for what appears to be so many quotes is that you
have to use two quotes to represent one quote when it is
inside another set of quotes.
--
Marsh
MVP [MS Access]


ok sorry to be a pain but this is really starting to annoy me now.

The forms i have are :- Supplier Select (Form1)
Supplier Enquiry (Form2)

Form1 Recordsource is Supplier Details Table
Form2 RecordSource is Supplier Details Table

The idea is to type a supplier name into the supplier name text box on form1
and it will open form2 with all the text boxes filled with the details from
the supplier details table.

in the Afterupdateof form1 the code is :-

Docmd.openform "Supplier Enquiry",,,"supplier name=" & me.Supplier_name

i am obviously going wrong somewhere so any help would be appriciated
 
Excellent thanks for all your help

Got it working but i keep getting a box telling me that it will create
duplicate changes .
i dont want it to write to the table i only want it to take details from the
table and enter them into form2

Marshall Barton said:
Ah ha! That's it. The supplier name is a text string so it
must be enclosed in quotes:

Docmd.openform "Supplier Enquiry",,, _
"supplier name=""" & me.Supplier_name & """"

The reason for what appears to be so many quotes is that you
have to use two quotes to represent one quote when it is
inside another set of quotes.
--
Marsh
MVP [MS Access]


ok sorry to be a pain but this is really starting to annoy me now.

The forms i have are :- Supplier Select (Form1)
Supplier Enquiry (Form2)

Form1 Recordsource is Supplier Details Table
Form2 RecordSource is Supplier Details Table

The idea is to type a supplier name into the supplier name text box on form1
and it will open form2 with all the text boxes filled with the details from
the supplier details table.

in the Afterupdateof form1 the code is :-

Docmd.openform "Supplier Enquiry",,,"supplier name=" & me.Supplier_name

i am obviously going wrong somewhere so any help would be appriciated
 
What I've suggested will not change anything. It just opens
form2 with a list of contacts for the supplier in form1.

I have no iea what it might be, but there must be something
else going on to cause that message. Check to see if
there's any code behind form2 that dirties the record. Also
check to make sure the controls in form1 are set up
correctly (i.e. is the supplier control supposed to be bound
or unbound).

After you figure that out AND if you want to prevent users
from modifying the contact info in form2, you can set
form2's AllowEdits and AllowDeletions properties to No.
 
i have just noticed that no matter what i type into the textbox on supplier
Select (form1) it opens Supplier enquiry (form2) at the first record from
the supplier details table. Is there anyway to get it to open up form2 with
the correct record that was typed into form1.
thanks for the help so far.


Marshall Barton said:
What I've suggested will not change anything. It just opens
form2 with a list of contacts for the supplier in form1.

I have no iea what it might be, but there must be something
else going on to cause that message. Check to see if
there's any code behind form2 that dirties the record. Also
check to make sure the controls in form1 are set up
correctly (i.e. is the supplier control supposed to be bound
or unbound).

After you figure that out AND if you want to prevent users
from modifying the contact info in form2, you can set
form2's AllowEdits and AllowDeletions properties to No.
--
Marsh
MVP [MS Access]

Excellent thanks for all your help

Got it working but i keep getting a box telling me that it will create
duplicate changes .
i dont want it to write to the table i only want it to take details from the
table and enter them into form2
 
Back
Top