A Microsoft Office (Excel, Word) forum. OfficeFrustration

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.

Go Back   Home » OfficeFrustration forum » Microsoft Access » New Users
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Simple browse and edit procedure



 
 
Thread Tools Display Modes
  #1  
Old May 15th, 2004, 02:02 PM
Michael West
external usenet poster
 
Posts: n/a
Default 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  
Old May 15th, 2004, 02:53 PM
PC Datasheet
external usenet poster
 
Posts: n/a
Default 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  
Old May 17th, 2004, 01:14 AM
Michael West
external usenet poster
 
Posts: n/a
Default 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  
Old May 17th, 2004, 03:36 AM
Steve
external usenet poster
 
Posts: n/a
Default 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  
Old May 17th, 2004, 05:10 AM
Michael West
external usenet poster
 
Posts: n/a
Default 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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 04:02 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.