Hi Michael,
1. In code, you can use "Me" to reference the form that contains the code. If
you want to reference any control on your form, you use the expression:
Me!NameOfTheControl
example:
You have a textbox named MyTextbox on your form and you want to display the
value of the textbox in a message box when you click a button. You put the
following code in the click event of the button:
MsgBox Me!MyTextbox
2. The expression, "[PK] = " & Me!NameOfPKFieldOnForm, is the correct syntax
when the primary key is numeric. If it is a string then you need:
"[PK] = '" & Me!NameOfPKFieldOnForm & "'"
That's a single and a double quote after the equal sign and a double, single
and a double quote at the end.
3. Yes. Open the form in design view and select a field. Open properties and
go to the Events tab. Use the Double Click event wizard. The wizard will take
you to the code module behind the form and will create two lines of code.
Place the code you need between these two lines.
Steve
PC Datasheet
Michael West said:
I asked:
What's the easiest way to let users
browse all records using a data sheet and then
double click on a particular row to open that
record in a different form for editing?
PC said:
You need to change the form to a continuous form. Each record on the form
needs to contain the primary key (PK). In the double click event of one or
more fields you need the following code:
DoCmd.OpenForm "NameOfOtherForm",,,"[PK] = " & Me!NameOfPKFieldOnForm
Okay, I can see that this approach will work.
However, could you give me some detail
on that last bit -- after the " = " sign.
What is the " & Me! " doing, exactly?
And, should there be a close quotation mark somewhere?
Can I do this using the Event wizard, or where do
I go to enter this code?
Many thanks.