Opening a Form On Same Record

J

JamesJ

What is the syntax to open a single record form from a form
that has a list box and has the same record source as the
underlying form.
The ID field is ContactID.
I want to be able to move among the records on the single record form.

Thanks,
James
 
M

missinglinq via AccessMonster.com

You should use a combobox instead of a listbox, as the combobox has the
AutoExpand feature. This allows you to start typing info into the combobox
and it will go to the first record that matches. First you must have your
form set up to display the record you want to retrieve, i.e. you must have
controls set up with the appropriate Control Sources to bind them to the
fields you want displayed. Then simply:

Add a combo box to your form. The Combobox Wizard will pop up
Select "Find a record based on the value I selected in my combobox."
Hit Next.
From the same query as the form is based on, click on the field (ContactID in
your case) you're searching by to move it to the right side.
Hit Next.
Size the column appropriately.
Hit Next.
Name the combobox.
Hit Finish.

Now you can drop the combobox down and scroll down to the item to search by,
or you can start to enter the item, and the combobox will "autofill" as you
type.
Hit <Enter> and the record will be retrieved.

Good Luck!

--
There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000

Message posted via AccessMonster.com
 
J

JamesJ

Forget the list box. I want ot select a record in a cointinuous form
and click a button and open a form to that record.

James
 
D

Damon Heron

Try a double-click event on the field of your choice, like this:

Private Sub txtCustomerID_DblClick(Cancel As Integer)
DoCmd.OpenForm "Customers", acNormal, , "CustomerID= " & "'" & txtCustomerID
& "'", acFormEdit, acDialog
' The customerID in this case is text value, if numerical, drop the " ' "
quotes.
End Sub

Damon
 
J

JamesJ

Can't get it to work.

DoCmd.OpenForm "frmContactsEdit", acNormal, , "ContactID= " & ContactID &
acFormEdit, acDialog

I removed the "'"

I need to use ContactID which is an autonumber filed 'cause using my text
field I get
a syntax error on values such as Joe's Garage because of the quote.

James
 
D

Damon Heron

Your answer is missing a comma - could that be the problem? Also, the where
section: "ContactID = " & ContactID is comparing the columnname in your
table "contactID" with the field on your form named ContactID. If you want
to make it clearer, name the field on your form "txtContactID", so the line
would look like this:

DoCmd.OpenForm "frmContactsEdit", acNormal, , "ContactID = " & txtContactID,
acFormEdit, acDialog

Also, the frmContactsEdit has to have a contactID on it.

Damon
 
J

JamesJ

That worked but The ContactID field is the same field on both
forms, why name it something else on the other form?

James
 

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

Top