473,400 Members | 2,163 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,400 software developers and data experts.

Position a list to a record?

When I activate frmList.List0, it positions at the end of the table:
- frmList
Private Sub Form_Activate()
Me.List0.SetFocus
Me.List0.ListIndex = Me.List0.ListCount - 1
-

When I DblClick a row in frmList.List0, I close frmList and open frmEdit to
edit record I clicked on:
-frmList
Private Sub List0_DblClick(Cancel As Integer)
Dim strWhere As String
strWhere = "WPS = " & Me.List0.Value
Zindex = Me.List0.ListIndex 'can Zindex somehow be used to reposition
when I activate next time?
DoCmd.Close
DoCmd.OpenForm "frmEdit", , , strWhere
End Sub
-

After I edit the record I exit frmEdit and activate frmList again:
-frmEdit
Private Sub cmdExit_Click()
DoCmd.Close
DoCmd.OpenForm "frmList"
End Sub
-

How can I return to frmList and have List0 positioned at the record I was on
when I DblClicked?

I tried changing the frmList activate event to:
-frmList
Private Sub Form_Activate()
Me.List0.SetFocus
If Not IsNull(Zindex) Then
Me.List0.ListIndex = Me.List0.ListCount - 1
Else
Me.List0.ListIndex = Zindex
End If
-

But this is not working.

Please help
Bill
Nov 12 '05 #1
3 3588
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Just don't close frmList - the selection indicator will remain on the
last selected item. Get rid of the Form_Activate - 'cuz it puts the
selection indicator at the bottom of the list everytime the form is
activated. If you don't close frmList you could put the code for
Form_Activate in the Form_Open event - then the selection indicator
won't always move to the bottom of the list when frmList is re
activated.

If you really don't want to do it my way - change the frmList's
Form_Activate routine. (I'm assuming that the variable Zindex is a
global variable.)

Private Sub Form_Activate()
Me!List0.SetFocus
If Zindex = 0 Then
Me!List0.ListIndex = Me!List0.ListCount - 1
Else
Me!List0.ListIndex = Zindex
End If
End Sub

HTH,

MGFoster:::mgf
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBP5cNDIechKqOuFEgEQKQpACfdjx0GgWbz4roAlkpyTTygR v/HX8AnRXj
f/bQ/kwz0e0HE1/qVlLqnbzq
=Rzhk
-----END PGP SIGNATURE-----

BillB wrote:
When I activate frmList.List0, it positions at the end of the table:
- frmList
Private Sub Form_Activate()
Me.List0.SetFocus
Me.List0.ListIndex = Me.List0.ListCount - 1
-

When I DblClick a row in frmList.List0, I close frmList and open frmEdit to
edit record I clicked on:
-frmList
Private Sub List0_DblClick(Cancel As Integer)
Dim strWhere As String
strWhere = "WPS = " & Me.List0.Value
Zindex = Me.List0.ListIndex 'can Zindex somehow be used to reposition
when I activate next time?
DoCmd.Close
DoCmd.OpenForm "frmEdit", , , strWhere
End Sub
-

After I edit the record I exit frmEdit and activate frmList again:
-frmEdit
Private Sub cmdExit_Click()
DoCmd.Close
DoCmd.OpenForm "frmList"
End Sub
-

How can I return to frmList and have List0 positioned at the record I was on
when I DblClicked?

I tried changing the frmList activate event to:
-frmList
Private Sub Form_Activate()
Me.List0.SetFocus
If Not IsNull(Zindex) Then
Me.List0.ListIndex = Me.List0.ListCount - 1
Else
Me.List0.ListIndex = Zindex
End If
-

But this is not working.

Please help
Bill


Nov 12 '05 #2

"MGFoster" <me@privacy.com> wrote in message
news:92*****************@newsread3.news.pas.earthl ink.net...
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Just don't close frmList - the selection indicator will remain on the
last selected item. Get rid of the Form_Activate - 'cuz it puts the
selection indicator at the bottom of the list everytime the form is
activated. If you don't close frmList you could put the code for
Form_Activate in the Form_Open event - then the selection indicator
won't always move to the bottom of the list when frmList is re
activated.
Thanks MG,
That was too easy!!

I had already tried what you said below using Zindex, but could not get that
to work. I think my problem with that method is that I am not sure how to
define a globle variable. I know many people here do not like to use them,
but I want to know why it didn't work.
I put this statement:
Public Zindex As Integer
at the top of the code in the form module (general declarations ). I also
tried it in Module1. When a form closed the value of Zindex showed in the
watch window as out of context. Am I missing something about defining a
global variable?

Bill
If you really don't want to do it my way - change the frmList's
Form_Activate routine. (I'm assuming that the variable Zindex is a
global variable.)

Private Sub Form_Activate()
Me!List0.SetFocus
If Zindex = 0 Then
Me!List0.ListIndex = Me!List0.ListCount - 1
Else
Me!List0.ListIndex = Zindex
End If
End Sub

HTH,

MGFoster:::mgf
Oakland, CA (USA)

I already had tried that second way.
Nov 12 '05 #3
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Try this definition in the Description section of a standard module:

Global ZIndex As Integer

If you put a variable definition in the Description section of a form
module it is only a module variable - its scope is the form.
Everytime the form closes the variable goes out of scope.

- --
MGFoster:::mgf
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBP5hZE4echKqOuFEgEQJULgCgxKEXLOJJM9wFkYKsQf3mbX I2RrsAoPef
pSLbEkot/IOPJhqtZIQYAFaH
=6kPn
-----END PGP SIGNATURE-----

BillB wrote:
"MGFoster" <me@privacy.com> wrote in message
news:92*****************@newsread3.news.pas.earthl ink.net...
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Just don't close frmList - the selection indicator will remain on the
last selected item. Get rid of the Form_Activate - 'cuz it puts the
selection indicator at the bottom of the list everytime the form is
activated. If you don't close frmList you could put the code for
Form_Activate in the Form_Open event - then the selection indicator
won't always move to the bottom of the list when frmList is re
activated.

Thanks MG,
That was too easy!!

I had already tried what you said below using Zindex, but could not get that
to work. I think my problem with that method is that I am not sure how to
define a globle variable. I know many people here do not like to use them,
but I want to know why it didn't work.
I put this statement:
Public Zindex As Integer
at the top of the code in the form module (general declarations ). I also
tried it in Module1. When a form closed the value of Zindex showed in the
watch window as out of context. Am I missing something about defining a
global variable?

Bill

If you really don't want to do it my way - change the frmList's
Form_Activate routine. (I'm assuming that the variable Zindex is a
global variable.)

Private Sub Form_Activate()
Me!List0.SetFocus
If Zindex = 0 Then
Me!List0.ListIndex = Me!List0.ListCount - 1
Else
Me!List0.ListIndex = Zindex
End If
End Sub

HTH,

MGFoster:::mgf
Oakland, CA (USA)


I already had tried that second way.


Nov 12 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Rowan | last post by:
Hi there, it has been a while since i have posted. I am in a situation where I am stumped. I am learning to build a dts package where I am connecting to a table in an AS400. This database is...
4
by: Christopher Weaver | last post by:
How do I retrieve the position value after successfully finding the row that I'm looking for? I need to set BindingManagerBase.Position so that all of the controls on the form are...
7
by: Eric | last post by:
I am trying to save the "last read" position of a file using a StreamReader object. I am reading the lines of the file using StreamReader.ReadLine and then saving the current position in the...
3
by: Mark Vergara | last post by:
Hi to all, I want to know if there is a way of getting the position of the particular record in the dataset aside from CurrencyManger.position let say for example we have a record.. cntID ...
3
by: zhouzhendong | last post by:
I have a form that shows a table in single form format. how can I know the position of the record the form is current showing so that I can enable or disable some buttons according to the position...
1
by: Karthiga1984 | last post by:
Hi Table Structure company name Phone No Products Example Company Name Phone No Products
16
by: ulam | last post by:
I have a form shown in datasheet view, and I have some actions that require that form to be requeried with a delete operation, however number of rows in the datasheet view remains constant with a...
0
by: jegathees | last post by:
Hi Friends, I am working in SAP XI Platform. In this, we use XSLT Mapping. I am facing one problem to print in field 'RecordID' starts from 1,2,3 in the target structure for those records...
14
by: lee | last post by:
hi, i have a dictionary as follows : kev : {'phno': , 'email': , 'name': , 'address': } if user is enters the 3rd item of key phno, ie "dfsdf" in my dict, how can i find it is the third item...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.