If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Simple browse and edit procedure
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? -- Michael West |
#2
|
|||
|
|||
Simple browse and edit procedure
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 -- PC Datasheet Your Resource For Help With Access, Excel And Word Applications www.pcdatasheet.com "Michael West" wrote in message ... 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? -- Michael West |
#3
|
|||
|
|||
Simple browse and edit procedure
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 Datasheet wrote: 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. -- Michael West |
#4
|
|||
|
|||
Simple browse and edit procedure
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" wrote in message ... 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 Datasheet wrote: 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. -- Michael West |
#5
|
|||
|
|||
Simple browse and edit procedure
Very helpful! Thanks Steve.
-- MW Steve wrote: 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" wrote in message ... 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 Datasheet wrote: 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. -- Michael West -- Michael West |
Thread Tools | |
Display Modes | |
|
|