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 » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

unbound listbox... how do i make the current record selected



 
 
Thread Tools Display Modes
  #1  
Old March 25th, 2010, 10:26 PM posted to microsoft.public.access.forms
dannie
external usenet poster
 
Posts: 25
Default unbound listbox... how do i make the current record selected

I have a listbox that displays the name of all the records, as I use the
navigation buttons to go through different records my listbox does not update
what it has selected.

My listbox is unbound and here are some things you might want to know:

Row Source:
SELECT InspectionsDI.ID, InspectionsDI.[Manhole Number] FROM [InspectionsDI
Query];

Private Sub lstDI_AfterUpdate()
DoCmd.GoToRecord acDataForm, "DropInletForm", acGoTo, lstDI.ListIndex + 1
End Sub

Thanks for help
  #2  
Old March 25th, 2010, 10:40 PM posted to microsoft.public.access.forms
Dirk Goldgar
external usenet poster
 
Posts: 2,529
Default unbound listbox... how do i make the current record selected

"dannie" wrote in message
...
I have a listbox that displays the name of all the records, as I use the
navigation buttons to go through different records my listbox does not
update
what it has selected.

My listbox is unbound and here are some things you might want to know:

Row Source:
SELECT InspectionsDI.ID, InspectionsDI.[Manhole Number] FROM
[InspectionsDI
Query];

Private Sub lstDI_AfterUpdate()
DoCmd.GoToRecord acDataForm, "DropInletForm", acGoTo, lstDI.ListIndex + 1
End Sub

Thanks for help



Is it that you want the list box to automatically show as selected the
record that is current? If the bound column of the list box is the first
column (the ID field), then you might use this code in the form's Current
event:

'------ start of code ------
Private Sub Form_Current()

Me.lstDI = Me!ID

End Sub
'------ end of code ------


--
Dirk Goldgar, MS Access MVP
Access tips: www.datagnostics.com/tips.html

(please reply to the newsgroup)

  #3  
Old March 25th, 2010, 10:43 PM posted to microsoft.public.access.forms
Dirk Goldgar
external usenet poster
 
Posts: 2,529
Default unbound listbox... how do i make the current record selected

"dannie" wrote in message
...
I have a listbox that displays the name of all the records, as I use the
navigation buttons to go through different records my listbox does not
update
what it has selected.

My listbox is unbound and here are some things you might want to know:

Row Source:
SELECT InspectionsDI.ID, InspectionsDI.[Manhole Number] FROM
[InspectionsDI
Query];

Private Sub lstDI_AfterUpdate()
DoCmd.GoToRecord acDataForm, "DropInletForm", acGoTo, lstDI.ListIndex + 1
End Sub

Thanks for help



Incidentally, I would probably do this somewhat differently, so that I would
have an option to sort the list box or the form differently:

Private Sub lstDI_AfterUpdate()

With Me.lstDI
If Not IsNull(.Value) Then
Me.Recordset.FindFirst "ID = " & .Value
End If
End With

End Sub

By making the navgation data-based, rather than sequence-based, you avoid
having problems if the list box and form aren't sorted the same way.

--
Dirk Goldgar, MS Access MVP
Access tips: www.datagnostics.com/tips.html

(please reply to the newsgroup)

  #4  
Old March 26th, 2010, 06:13 PM posted to microsoft.public.access.forms
dannie
external usenet poster
 
Posts: 25
Default unbound listbox... how do i make the current record selected

I tested that out and it worked great, now I need to figure out how to do it
from my code module because my OnCurrent event has a function name which
calls a function from a module. I dont know how to have it call that
function and do a event procedure.

"Dirk Goldgar" wrote:

"dannie" wrote in message
...
I have a listbox that displays the name of all the records, as I use the
navigation buttons to go through different records my listbox does not
update
what it has selected.

My listbox is unbound and here are some things you might want to know:

Row Source:
SELECT InspectionsDI.ID, InspectionsDI.[Manhole Number] FROM
[InspectionsDI
Query];

Private Sub lstDI_AfterUpdate()
DoCmd.GoToRecord acDataForm, "DropInletForm", acGoTo, lstDI.ListIndex + 1
End Sub

Thanks for help



Is it that you want the list box to automatically show as selected the
record that is current? If the bound column of the list box is the first
column (the ID field), then you might use this code in the form's Current
event:

'------ start of code ------
Private Sub Form_Current()

Me.lstDI = Me!ID

End Sub
'------ end of code ------


--
Dirk Goldgar, MS Access MVP
Access tips: www.datagnostics.com/tips.html

(please reply to the newsgroup)

  #5  
Old March 26th, 2010, 07:09 PM posted to microsoft.public.access.forms
Dirk Goldgar
external usenet poster
 
Posts: 2,529
Default unbound listbox... how do i make the current record selected

"dannie" wrote in message
...
I tested that out and it worked great, now I need to figure out how to do
it
from my code module because my OnCurrent event has a function name which
calls a function from a module. I dont know how to have it call that
function and do a event procedure.


Call the function from the event procedure, before or after new code for the
event. For example:

'------ start of code ------
Private Sub Form_Current()

Me.lstDI = Me!ID

Call YourFunction()

End Sub
'------ end of code ------


--
Dirk Goldgar, MS Access MVP
Access tips: www.datagnostics.com/tips.html

(please reply to the newsgroup)

 




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 08:50 AM.


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