Linking forms with 2 field primary key defined

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

Guest

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"
 
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
 
Back
Top