Linking forms with 2 field primary key defined

L

Linda-Jeanne

I need to carry a record from a continuous form to another form by specifying both fields of my primary key. The button wizard only allows you to specify one field to open the new form. I have monkeyed around with the code to try and include both fields, but haven't been able to get it to work. If anyone can help, I'd be most appreciative

Linda-Jeann
"At my wits end in the frozen north"
 
A

Albert D. Kallal

If you talking about a button on the eh continuous form to open up the
current record, then you should probably just add a autonumber field to the
table. That way, you have no need to use two fields.

You then can use:

dim strWhere as string

strWhere = "id = " & me.id
me.Refresh
docmd.OpenForm "frmEditDetails",,,strWhere

If you must, and need to use two fields, then you can certainly use:

dim strWhere as string

"id = " & me.id & " and Location = '" & me.Location & "'"
docmd.OpenForm "frmEditDetials",,,strWhere

Note that the standard sql rules apply when building the "where condition.
That means number fields don't need to be surrounded by quotes, but string
fields do.

If fact, if you look at the follwing screen shots, I use the exact above
code behind the "glasses" buttion to open up more detals. Take quick look at
the follwing for some continues form ideas:

http://www.attcanada.net/~kallal.msn/Articles/Grid.htm
 

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