Getting focus on a contnuous form record via cmd btn

G

Guest

Access 2003

I have a continuous form that has a bunch of records. Each record has an
"EDIT" button that I want to open a subform allowing edits of the particular
form. This only partially works however. I have to first select a field on
the record to make the record "active". Then I hit the button and it works
fine.

What code do I need to make a cmd button make the record you click on active?

TIA

Aaron G
Philadelphia, PA
 
D

Dirk Goldgar

Aaron G said:
Access 2003

I have a continuous form that has a bunch of records. Each record
has an "EDIT" button that I want to open a subform allowing edits of
the particular form. This only partially works however. I have to
first select a field on the record to make the record "active". Then
I hit the button and it works fine.

What code do I need to make a cmd button make the record you click on
active?

That doesn't make sense to me, Aaron. If the button is on the detail
section of the continuous form, then clicking on the button in a
particular row should make that row's record the current record (which
is what I take it you mean by "active"). What is the code behind the
button, and what error are you getting that makes you think it isn't
doing that?
 
G

Guest

Dirk,

That's what I thought should happen as well. Here's what happens... say a
contact has three notes in a continuous subform. In each record I've made a
button (out of a text box - for looks) with the following code:

Private Sub btnEditJournal_Click()
On Error GoTo Err_btnEditJournal_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "JournalsClientsEditPopup"

stLinkCriteria = "[JournalsConversationsID]=" &
Me![JournalsConversationsID]
DoCmd.OpenForm stDocName, , , stLinkCriteria, , acDialog
Form_JournalsClientsSub.Requery

Exit_btnEditJournal_Click:
Exit Sub

Err_btnEditJournal_Click:
MsgBox Err.Description
Resume Exit_btnEditJournal_Click
End Sub

However, when if I click on a button without clicking elsewhere on the
record, then it brings up the top records information. I left the record
selectors visible so I can clearly see that it isn't picking the current
record. If I DO click somewhere else on the current record first, then the
button works just fine.

Is there a command line I can put in to make the current record active?

TIA

Aaron G
Philadelphia, PA
 
D

Dirk Goldgar

Aaron G said:
Dirk,

That's what I thought should happen as well. Here's what happens...
say a contact has three notes in a continuous subform. In each
record I've made a button (out of a text box - for looks) with the
following code:
[snip]

What exactly do you mean when you say you made a button out of a text
box? I suspect that you are actually using a label as if it were a
button -- but it isn't a button, and won't behave the same way, so
calling it a button is misleading. A little experimentation
demonstrates that while clicking on a non-attached label on a continuous
form will fire the label's Click event, it won't affect the form's
Current record in any way, because the control can't receive the focus.

If you really want to use a label, instead of a true command button or
some other control that can receive the focus, how about putting a
*transparent* command button on top of the label, and using that
button's Click property to run your code? In case you didn't know,
command buttons have a Transparent property, so you can have a
functional but invisible command button.
 
G

Guest

Dirk,

That works perfectly! Thanks for the help.

Aaron G
Philadelphia, PA

Dirk Goldgar said:
Aaron G said:
Dirk,

That's what I thought should happen as well. Here's what happens...
say a contact has three notes in a continuous subform. In each
record I've made a button (out of a text box - for looks) with the
following code:
[snip]

What exactly do you mean when you say you made a button out of a text
box? I suspect that you are actually using a label as if it were a
button -- but it isn't a button, and won't behave the same way, so
calling it a button is misleading. A little experimentation
demonstrates that while clicking on a non-attached label on a continuous
form will fire the label's Click event, it won't affect the form's
Current record in any way, because the control can't receive the focus.

If you really want to use a label, instead of a true command button or
some other control that can receive the focus, how about putting a
*transparent* command button on top of the label, and using that
button's Click property to run your code? In case you didn't know,
command buttons have a Transparent property, so you can have a
functional but invisible command button.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)
 
G

Guest

Dirk Goldgar,

I have same problem and I looking for yours solution but why I can not see
yours sample code?

thanks

Dirk Goldgar said:
Aaron G said:
Dirk,

That's what I thought should happen as well. Here's what happens...
say a contact has three notes in a continuous subform. In each
record I've made a button (out of a text box - for looks) with the
following code:
[snip]

What exactly do you mean when you say you made a button out of a text
box? I suspect that you are actually using a label as if it were a
button -- but it isn't a button, and won't behave the same way, so
calling it a button is misleading. A little experimentation
demonstrates that while clicking on a non-attached label on a continuous
form will fire the label's Click event, it won't affect the form's
Current record in any way, because the control can't receive the focus.

If you really want to use a label, instead of a true command button or
some other control that can receive the focus, how about putting a
*transparent* command button on top of the label, and using that
button's Click property to run your code? In case you didn't know,
command buttons have a Transparent property, so you can have a
functional but invisible command button.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)
 
D

Dirk Goldgar

A Newbie said:
Dirk Goldgar,

I have same problem and I looking for yours solution but why I can
not see yours sample code?

thanks

Dirk Goldgar said:
Aaron G said:
Dirk,

That's what I thought should happen as well. Here's what happens...
say a contact has three notes in a continuous subform. In each
record I've made a button (out of a text box - for looks) with the
following code:
[snip]

What exactly do you mean when you say you made a button out of a text
box? I suspect that you are actually using a label as if it were a
button -- but it isn't a button, and won't behave the same way, so
calling it a button is misleading. A little experimentation
demonstrates that while clicking on a non-attached label on a
continuous form will fire the label's Click event, it won't affect
the form's Current record in any way, because the control can't
receive the focus.

If you really want to use a label, instead of a true command button
or some other control that can receive the focus, how about putting a
*transparent* command button on top of the label, and using that
button's Click property to run your code? In case you didn't know,
command buttons have a Transparent property, so you can have a
functional but invisible command button.

I didn't post any sample code. Aaron G, who asked the original
question, posted the code he had for his control's Click event in an
earlier message in this thread. I just suggested he move it to the
Click event of a transparent command button.

What exactly is the problem you are having?
 

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