Double-click a continous form to get an entry form

G

Guest

I have a continous form that lists the records in a table. I want the user to
be able to double-click on one of the rows in the form to open an entry form
to edit the record. I have not been able to figure out how to do this. Any
suggestions?
-rg
 
G

Guest

Hi

Places this behind the on double click event

Private Sub Form_DblClick()
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "NewForm"
stLinkCriteria = "[IDFieldOnNewForm]=" & Me![IDFieldOn1stForm]
DoCmd.OpenForm stDocName, , , stLinkCriteria
End Sub


Ensure that your have the record selector set to = Yes on the contious form
(you will double click this to action the event).
Create a "NewForm" to edit the details you want (poss a popup)
Ensure there is a common field on both forms (I have shown ID field in the
code but it may be different in your D Base)

Change "IDFieldOnNewForm" and "IDFieldOn1stForm" to what they are. Also
change the "NewForm" name to what it is

Hope this helps
 
S

Steve Schapel

Rg,

If you are using the Record Selector, as suggested by Wayne, I would
recommend using the Click event rather than DblClick. Just simpler,
that's all.

Speaking of simpler ;-) why not put the code in one line? ...
Private Sub Form_Click()
DoCmd.OpenForm "NewForm", , , "[IDFieldOnNewForm]=" &
Me.IDFieldOn1stForm
End Sub
 
G

Guest

Ha Ha yes you are correct again in making the code shorter (I like simple
"Stuff")

I do not have any double click events any D Bases that I look after but the
original post was
I want the user to be able to double-click on one of the rows
this is why I did this

You and Dirk are keeping eye on my answers today which is very good as it
keeps my on me toes :cool:


Buon anno nuovo a tutti.

--
Wayne
Manchester, England.



Steve Schapel said:
Rg,

If you are using the Record Selector, as suggested by Wayne, I would
recommend using the Click event rather than DblClick. Just simpler,
that's all.

Speaking of simpler ;-) why not put the code in one line? ...
Private Sub Form_Click()
DoCmd.OpenForm "NewForm", , , "[IDFieldOnNewForm]=" &
Me.IDFieldOn1stForm
End Sub

--
Steve Schapel, Microsoft Access MVP

Wayne-I-M said:
Hi

Places this behind the on double click event

Private Sub Form_DblClick()
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "NewForm"
stLinkCriteria = "[IDFieldOnNewForm]=" & Me![IDFieldOn1stForm]
DoCmd.OpenForm stDocName, , , stLinkCriteria
End Sub


Ensure that your have the record selector set to = Yes on the contious form
(you will double click this to action the event).
Create a "NewForm" to edit the details you want (poss a popup)
Ensure there is a common field on both forms (I have shown ID field in the
code but it may be different in your D Base)

Change "IDFieldOnNewForm" and "IDFieldOn1stForm" to what they are. Also
change the "NewForm" name to what it is

Hope this helps
 
G

Guest

Ciao Steve

Me dispiace ma il mio Inglese fa schiffo

- - - - - - - - - - - - - - - - - - - - - - - - - -

Happy New Year to you and your family
 
G

Guest

Ok,
Thanks for the prompt reply.
I tried what you said, but I must have something set wrong in the form. Do I
need to do something to be able to use the Record Selector?

The code I put in was
Private Sub Form_DblClick(Cancel As Integer)
DoCmd.OpenForm "TaskEntry", , , "[TaskEntry.TaskID]=" & Me.TaskID
End Sub

Currently, the form allows data entry. It is not opening a new form, but I'm
so new to this, I probably am not referencing the fields/forms correctly
either. Thanks for your help.
-rg

Wayne-I-M said:
Ha Ha yes you are correct again in making the code shorter (I like simple
"Stuff")

I do not have any double click events any D Bases that I look after but the
original post was
I want the user to be able to double-click on one of the rows
this is why I did this

You and Dirk are keeping eye on my answers today which is very good as it
keeps my on me toes :cool:


Buon anno nuovo a tutti.

--
Wayne
Manchester, England.



Steve Schapel said:
Rg,

If you are using the Record Selector, as suggested by Wayne, I would
recommend using the Click event rather than DblClick. Just simpler,
that's all.

Speaking of simpler ;-) why not put the code in one line? ...
Private Sub Form_Click()
DoCmd.OpenForm "NewForm", , , "[IDFieldOnNewForm]=" &
Me.IDFieldOn1stForm
End Sub

--
Steve Schapel, Microsoft Access MVP

Wayne-I-M said:
Hi

Places this behind the on double click event

Private Sub Form_DblClick()
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "NewForm"
stLinkCriteria = "[IDFieldOnNewForm]=" & Me![IDFieldOn1stForm]
DoCmd.OpenForm stDocName, , , stLinkCriteria
End Sub


Ensure that your have the record selector set to = Yes on the contious form
(you will double click this to action the event).
Create a "NewForm" to edit the details you want (poss a popup)
Ensure there is a common field on both forms (I have shown ID field in the
code but it may be different in your D Base)

Change "IDFieldOnNewForm" and "IDFieldOn1stForm" to what they are. Also
change the "NewForm" name to what it is

Hope this helps
 
G

Guest

I have taken the liberty of using Steves idea (hope he will not mind) as it
is shorter than the code I gave which I thing is esier to understand for
users.

Please behind the OnClick event on the form (not the control)

Private Sub Form_Click()
DoCmd.OpenForm "TaskEntry", , , "[TaskID]=" & Me.TaskID
End Sub


--
Wayne
Manchester, England.



rg said:
Ok,
Thanks for the prompt reply.
I tried what you said, but I must have something set wrong in the form. Do I
need to do something to be able to use the Record Selector?

The code I put in was
Private Sub Form_DblClick(Cancel As Integer)
DoCmd.OpenForm "TaskEntry", , , "[TaskEntry.TaskID]=" & Me.TaskID
End Sub

Currently, the form allows data entry. It is not opening a new form, but I'm
so new to this, I probably am not referencing the fields/forms correctly
either. Thanks for your help.
-rg

Wayne-I-M said:
Ha Ha yes you are correct again in making the code shorter (I like simple
"Stuff")

I do not have any double click events any D Bases that I look after but the
original post was
I want the user to be able to double-click on one of the rows
this is why I did this

You and Dirk are keeping eye on my answers today which is very good as it
keeps my on me toes :cool:


Buon anno nuovo a tutti.

--
Wayne
Manchester, England.



Steve Schapel said:
Rg,

If you are using the Record Selector, as suggested by Wayne, I would
recommend using the Click event rather than DblClick. Just simpler,
that's all.

Speaking of simpler ;-) why not put the code in one line? ...
Private Sub Form_Click()
DoCmd.OpenForm "NewForm", , , "[IDFieldOnNewForm]=" &
Me.IDFieldOn1stForm
End Sub

--
Steve Schapel, Microsoft Access MVP

Wayne-I-M wrote:
Hi

Places this behind the on double click event

Private Sub Form_DblClick()
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "NewForm"
stLinkCriteria = "[IDFieldOnNewForm]=" & Me![IDFieldOn1stForm]
DoCmd.OpenForm stDocName, , , stLinkCriteria
End Sub


Ensure that your have the record selector set to = Yes on the contious form
(you will double click this to action the event).
Create a "NewForm" to edit the details you want (poss a popup)
Ensure there is a common field on both forms (I have shown ID field in the
code but it may be different in your D Base)

Change "IDFieldOnNewForm" and "IDFieldOn1stForm" to what they are. Also
change the "NewForm" name to what it is

Hope this helps
 
S

Steve Schapel

Rg,

Just for clarity, note that this assumes you will click the Record
Selector [|>] at the left of the applicable record on the continuous
form. It will not work if you click the data controls or anywhere in
the detail section of the form.

Also, it assumes that TaskID is a number data type. If it is text, you
will need to change it to...
DoCmd.OpenForm "TaskEntry", , , "[TaskID]='" & Me.TaskID & "'"

Er, you do have a form named TaskEntry, right?
 
G

Guest

I fixed the DoCmd line, but I am still not getting the new form to open. It
is putting me in the field on my continous record form to edit.
-rg

Wayne-I-M said:
I have taken the liberty of using Steves idea (hope he will not mind) as it
is shorter than the code I gave which I thing is esier to understand for
users.

Please behind the OnClick event on the form (not the control)

Private Sub Form_Click()
DoCmd.OpenForm "TaskEntry", , , "[TaskID]=" & Me.TaskID
End Sub


--
Wayne
Manchester, England.



rg said:
Ok,
Thanks for the prompt reply.
I tried what you said, but I must have something set wrong in the form. Do I
need to do something to be able to use the Record Selector?

The code I put in was
Private Sub Form_DblClick(Cancel As Integer)
DoCmd.OpenForm "TaskEntry", , , "[TaskEntry.TaskID]=" & Me.TaskID
End Sub

Currently, the form allows data entry. It is not opening a new form, but I'm
so new to this, I probably am not referencing the fields/forms correctly
either. Thanks for your help.
-rg
 
S

Steve Schapel

Cheers, Wayne. What you put is the kind of code that the wizards and
such create. But I generally consider that the purpose of variables is
to make the code simpler or more efficient, and try to use them
accordingly :)
 
G

Guest

Thanks Steve and Wayne,
I was not clicking on the Record Selector. I did that, and got a syntax
error, so I cut and pasted the line of code rather than typing it in. I had
missed the single quote between the double quotes at the end of the line of
code. Now it works great.
-rg

Steve Schapel said:
Rg,

Just for clarity, note that this assumes you will click the Record
Selector [|>] at the left of the applicable record on the continuous
form. It will not work if you click the data controls or anywhere in
the detail section of the form.

Also, it assumes that TaskID is a number data type. If it is text, you
will need to change it to...
DoCmd.OpenForm "TaskEntry", , , "[TaskID]='" & Me.TaskID & "'"

Er, you do have a form named TaskEntry, right?

--
Steve Schapel, Microsoft Access MVP

Wayne-I-M said:
I have taken the liberty of using Steves idea (hope he will not mind) as it
is shorter than the code I gave which I thing is esier to understand for
users.

Please behind the OnClick event on the form (not the control)

Private Sub Form_Click()
DoCmd.OpenForm "TaskEntry", , , "[TaskID]=" & Me.TaskID
End Sub
 
N

NDClark

Steve, I am having the same trouble with getting my entry form to open to the
record I click. I can get the form to open. It is just opening to the first
record. Please help if you will. I appreciate it. I am pulling my hair out
 

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