On Click from a List Box

S

Scuda

I have an unbound list box on a subform that displays specific records from
my table. Following some advice from here on what I wanted to do which is
Click on a record and have it open up to main form and go to that record. I
am having a little problem. It opens up the main form correctly but it goes
to the first Record, not the one I clicked.

I have the following code on my Open Record button on my subform:

On Error GoTo Err_cmd_open_record_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmSENESarLog2008"

stLinkCriteria = "[IncidentID]=" & Me![IncidentID]
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_cmd_open_record_Click:
Exit Sub

Err_cmd_open_record_Click:
MsgBox Err.Description
Resume Exit_cmd_open_record_Click

I was trying to follow the directions from
http://www.databasedev.co.uk/list_box_searching.html where I can double-click
on a record in the list box to take me there but that wasn't working, so the
above was created just using the command button wizard.

My table is tblSENEIncidentLog2008
My main form is frmSENESarLog2008
My sub form is subfrmSAR

Any help GREATLY appreciated!

Steph
 
B

boblarson

Is Incident ID a numeric datatype, or text datatype? If TEXT, then it would
be:

stLinkCriteria = "[IncidentID]='" & Me![IncidentID] & "'"

with a single quote after the = sign and a double quote, single quote,
double quote concatenated on after the Me![IncidentID].

--
Bob Larson
Access World Forums Super Moderator
Utter Access VIP
Tutorials at http://www.btabdevelopment.com
__________________________________
If my post was helpful to you, please rate the post.
 
S

Scuda

It is an Autonumber.

Thanks Bob.
S


boblarson said:
Is Incident ID a numeric datatype, or text datatype? If TEXT, then it would
be:

stLinkCriteria = "[IncidentID]='" & Me![IncidentID] & "'"

with a single quote after the = sign and a double quote, single quote,
double quote concatenated on after the Me![IncidentID].

--
Bob Larson
Access World Forums Super Moderator
Utter Access VIP
Tutorials at http://www.btabdevelopment.com
__________________________________
If my post was helpful to you, please rate the post.


Scuda said:
I have an unbound list box on a subform that displays specific records from
my table. Following some advice from here on what I wanted to do which is
Click on a record and have it open up to main form and go to that record. I
am having a little problem. It opens up the main form correctly but it goes
to the first Record, not the one I clicked.

I have the following code on my Open Record button on my subform:

On Error GoTo Err_cmd_open_record_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmSENESarLog2008"

stLinkCriteria = "[IncidentID]=" & Me![IncidentID]
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_cmd_open_record_Click:
Exit Sub

Err_cmd_open_record_Click:
MsgBox Err.Description
Resume Exit_cmd_open_record_Click

I was trying to follow the directions from
http://www.databasedev.co.uk/list_box_searching.html where I can double-click
on a record in the list box to take me there but that wasn't working, so the
above was created just using the command button wizard.

My table is tblSENEIncidentLog2008
My main form is frmSENESarLog2008
My sub form is subfrmSAR

Any help GREATLY appreciated!

Steph
 
B

boblarson

Are you trying to have the subform open to a specific location? Or is it
just the record on the main form? Also, as it is currently, it looks like it
SHOULD work. So, some things to check:

1. Are all of the names the correct names. Is IncidentID the true name or
is it Incident_ID or Incident ID?

2. Make sure the Data Entry property of the form is not set to YES, but set
to NO.

Which version of Access are you using?
--
Bob Larson
Access World Forums Super Moderator
Utter Access VIP
Tutorials at http://www.btabdevelopment.com
__________________________________
If my post was helpful to you, please rate the post.


Scuda said:
It is an Autonumber.

Thanks Bob.
S


boblarson said:
Is Incident ID a numeric datatype, or text datatype? If TEXT, then it would
be:

stLinkCriteria = "[IncidentID]='" & Me![IncidentID] & "'"

with a single quote after the = sign and a double quote, single quote,
double quote concatenated on after the Me![IncidentID].

--
Bob Larson
Access World Forums Super Moderator
Utter Access VIP
Tutorials at http://www.btabdevelopment.com
__________________________________
If my post was helpful to you, please rate the post.


Scuda said:
I have an unbound list box on a subform that displays specific records from
my table. Following some advice from here on what I wanted to do which is
Click on a record and have it open up to main form and go to that record. I
am having a little problem. It opens up the main form correctly but it goes
to the first Record, not the one I clicked.

I have the following code on my Open Record button on my subform:

On Error GoTo Err_cmd_open_record_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmSENESarLog2008"

stLinkCriteria = "[IncidentID]=" & Me![IncidentID]
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_cmd_open_record_Click:
Exit Sub

Err_cmd_open_record_Click:
MsgBox Err.Description
Resume Exit_cmd_open_record_Click

I was trying to follow the directions from
http://www.databasedev.co.uk/list_box_searching.html where I can double-click
on a record in the list box to take me there but that wasn't working, so the
above was created just using the command button wizard.

My table is tblSENEIncidentLog2008
My main form is frmSENESarLog2008
My sub form is subfrmSAR

Any help GREATLY appreciated!

Steph
 
B

boblarson

Also, your listbox's MULTI-SELECT can't be set to anything other than NONE or
else it fails to have a value. The .Value property becomes 0 for any
multi-select listbox.
--
Bob Larson
Access World Forums Super Moderator
Utter Access VIP
Tutorials at http://www.btabdevelopment.com
__________________________________
If my post was helpful to you, please rate the post.


Scuda said:
It is an Autonumber.

Thanks Bob.
S


boblarson said:
Is Incident ID a numeric datatype, or text datatype? If TEXT, then it would
be:

stLinkCriteria = "[IncidentID]='" & Me![IncidentID] & "'"

with a single quote after the = sign and a double quote, single quote,
double quote concatenated on after the Me![IncidentID].

--
Bob Larson
Access World Forums Super Moderator
Utter Access VIP
Tutorials at http://www.btabdevelopment.com
__________________________________
If my post was helpful to you, please rate the post.


Scuda said:
I have an unbound list box on a subform that displays specific records from
my table. Following some advice from here on what I wanted to do which is
Click on a record and have it open up to main form and go to that record. I
am having a little problem. It opens up the main form correctly but it goes
to the first Record, not the one I clicked.

I have the following code on my Open Record button on my subform:

On Error GoTo Err_cmd_open_record_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmSENESarLog2008"

stLinkCriteria = "[IncidentID]=" & Me![IncidentID]
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_cmd_open_record_Click:
Exit Sub

Err_cmd_open_record_Click:
MsgBox Err.Description
Resume Exit_cmd_open_record_Click

I was trying to follow the directions from
http://www.databasedev.co.uk/list_box_searching.html where I can double-click
on a record in the list box to take me there but that wasn't working, so the
above was created just using the command button wizard.

My table is tblSENEIncidentLog2008
My main form is frmSENESarLog2008
My sub form is subfrmSAR

Any help GREATLY appreciated!

Steph
 
S

Scuda

Ok, checked all of that Bob, thanks. I have a form (4 of them) that log
different incidents (I am USCG), they are SAR, LE, ADMIN, MSIT. They are all
feeding one table tblSENEIncidentLog2008. From my list box, which shows me
all of a certain type of incident, I would like to click or double click the
incident and have it open that specific incident in the appropriate form
(log). So when I scroll down the listbox and find the incident I want, I
click or double click and it brings me to the main form and that specific
record.

I just went back in, and the button worked ONCE, but it did not bring me to
the specific record, but to the end. And when I tried it again, nothing
happened.

Thanks so much for all the help.

Steph

boblarson said:
Are you trying to have the subform open to a specific location? Or is it
just the record on the main form? Also, as it is currently, it looks like it
SHOULD work. So, some things to check:

1. Are all of the names the correct names. Is IncidentID the true name or
is it Incident_ID or Incident ID?

2. Make sure the Data Entry property of the form is not set to YES, but set
to NO.

Which version of Access are you using?
--
Bob Larson
Access World Forums Super Moderator
Utter Access VIP
Tutorials at http://www.btabdevelopment.com
__________________________________
If my post was helpful to you, please rate the post.


Scuda said:
It is an Autonumber.

Thanks Bob.
S


boblarson said:
Is Incident ID a numeric datatype, or text datatype? If TEXT, then it would
be:

stLinkCriteria = "[IncidentID]='" & Me![IncidentID] & "'"

with a single quote after the = sign and a double quote, single quote,
double quote concatenated on after the Me![IncidentID].

--
Bob Larson
Access World Forums Super Moderator
Utter Access VIP
Tutorials at http://www.btabdevelopment.com
__________________________________
If my post was helpful to you, please rate the post.


:

I have an unbound list box on a subform that displays specific records from
my table. Following some advice from here on what I wanted to do which is
Click on a record and have it open up to main form and go to that record. I
am having a little problem. It opens up the main form correctly but it goes
to the first Record, not the one I clicked.

I have the following code on my Open Record button on my subform:

On Error GoTo Err_cmd_open_record_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmSENESarLog2008"

stLinkCriteria = "[IncidentID]=" & Me![IncidentID]
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_cmd_open_record_Click:
Exit Sub

Err_cmd_open_record_Click:
MsgBox Err.Description
Resume Exit_cmd_open_record_Click

I was trying to follow the directions from
http://www.databasedev.co.uk/list_box_searching.html where I can double-click
on a record in the list box to take me there but that wasn't working, so the
above was created just using the command button wizard.

My table is tblSENEIncidentLog2008
My main form is frmSENESarLog2008
My sub form is subfrmSAR

Any help GREATLY appreciated!

Steph
 
S

Scuda

Ok, Bob (and all) getting closer I think.

In my subform (subSAR) I have the below in my After Update:
Private Sub ListSAR_AfterUpdate()

'Once a record is selected in the list, enable the showRecord button
ShowRecord.Enabled = True
' Find the record that matches the control.
Me.RecordsetClone.FindFirst "[IncidentID] = " & Me![ListSAR]
Me.Bookmark = Me.RecordsetClone.Bookmark
Me.Refresh
End Sub

Private Sub ListSAR_DblClick(Cancel As Integer)
Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmSENESarLog2008"

stLinkCriteria = "[IncidentID]=" & Me![IncidentID]
DoCmd.OpenForm stDocName, , , stLinkCriteria
End Sub

In my on Double Click I have this:

Private Sub ListSAR_AfterUpdate()

'Once a record is selected in the list, enable the showRecord button
ShowRecord.Enabled = True
' Find the record that matches the control.
Me.RecordsetClone.FindFirst "[IncidentID] = " & Me![ListSAR]
Me.Bookmark = Me.RecordsetClone.Bookmark
Me.Refresh
End Sub

Private Sub ListSAR_DblClick(Cancel As Integer)
Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmSENESarLog2008"

stLinkCriteria = "[IncidentID]=" & Me![IncidentID]
DoCmd.OpenForm stDocName, , , stLinkCriteria
End Sub

When I double click with JUST the subform open, it works great, goes right
to the correct record via the IncidentID. However when I access it through my
main form, it only goes to RECORD # 1, thats it, and it says filtered on the
bottom so I cannot scroll through those records.

Any ideas? Thanks so much in advance,

Steph

boblarson said:
Also, your listbox's MULTI-SELECT can't be set to anything other than NONE or
else it fails to have a value. The .Value property becomes 0 for any
multi-select listbox.
--
Bob Larson
Access World Forums Super Moderator
Utter Access VIP
Tutorials at http://www.btabdevelopment.com
__________________________________
If my post was helpful to you, please rate the post.


Scuda said:
It is an Autonumber.

Thanks Bob.
S


boblarson said:
Is Incident ID a numeric datatype, or text datatype? If TEXT, then it would
be:

stLinkCriteria = "[IncidentID]='" & Me![IncidentID] & "'"

with a single quote after the = sign and a double quote, single quote,
double quote concatenated on after the Me![IncidentID].

--
Bob Larson
Access World Forums Super Moderator
Utter Access VIP
Tutorials at http://www.btabdevelopment.com
__________________________________
If my post was helpful to you, please rate the post.


:

I have an unbound list box on a subform that displays specific records from
my table. Following some advice from here on what I wanted to do which is
Click on a record and have it open up to main form and go to that record. I
am having a little problem. It opens up the main form correctly but it goes
to the first Record, not the one I clicked.

I have the following code on my Open Record button on my subform:

On Error GoTo Err_cmd_open_record_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmSENESarLog2008"

stLinkCriteria = "[IncidentID]=" & Me![IncidentID]
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_cmd_open_record_Click:
Exit Sub

Err_cmd_open_record_Click:
MsgBox Err.Description
Resume Exit_cmd_open_record_Click

I was trying to follow the directions from
http://www.databasedev.co.uk/list_box_searching.html where I can double-click
on a record in the list box to take me there but that wasn't working, so the
above was created just using the command button wizard.

My table is tblSENEIncidentLog2008
My main form is frmSENESarLog2008
My sub form is subfrmSAR

Any help GREATLY appreciated!

Steph
 

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