Solved

Which cell i'm currently in ?

Posted on 2001-07-20
10
189 Views
Last Modified: 2008-03-17
Hi,

i have a form in datasheet view and i'd like to know how can i identify the cell i'm currently in.

Thanx
0
Comment
Question by:johnny_35
  • 4
  • 3
  • 2
  • +1
10 Comments
 
LVL 12

Expert Comment

by:Paurths
ID: 6301562
hi johnny_35,

here is an example

Private Sub MyField_GotFocus()
    MsgBox "Hi u are in field : " & Me.MyField.Name
End Sub

does this help,
or do u need to run a function or something on entering.... or something else?

cheers
Ricky
0
 

Author Comment

by:johnny_35
ID: 6301656
hi, Ricky

well, i need it for the following purpose:
as i said i have a form opened in datasheet view and i have set a shortcut menu with some options on it. these options make some changes to a field which contains states for all other fields. for example, i go into a cell, right-click, choose an option (let's say that the option sets that the current cell won't be printed in a report), and the field which contains the states changes as necessary. that field is a string and each character represents a state of other fields in the current record. the index of the character in this field represents the index of other fields in the row, so i need to know which field i'm currently in to properly update the field with the state. e.g, if i'm in the third field, the third character in the string must be changed. by the way, it isn't necessary that i get the numeric index of the field if it isn't possible...if i get the name, i'll  write a function to translate it to the correct field number...
0
 
LVL 54

Expert Comment

by:nico5038
ID: 6301726
You can use:

Me.ActiveControl.Name

Clear ?

Nic;o)
0
 
LVL 12

Expert Comment

by:Paurths
ID: 6301735
try

Screen.ActiveControl.Name

or

me.ActiveControle.Name
0
 
LVL 12

Expert Comment

by:Paurths
ID: 6301742
doh,
not again...
0
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
LVL 54

Expert Comment

by:nico5038
ID: 6302618
Yep ;-)
0
 
LVL 12

Expert Comment

by:Paurths
ID: 6302779
lol  :-)
0
 
LVL 2

Expert Comment

by:hotbudare
ID: 6304044
Since users can change column order of a form in datasheet view at run time, I don't think it's a good idea to relay on them. I think Nico's (and Paurths') idea are your best choice


HTH/EQTA
T.S.U. Mario Osorio
Punto Fijo, Falcon, Venezuela
0
 

Author Comment

by:johnny_35
ID: 6304461
Hi,


instead of using Screen.ActiveControl.Name as suggested, i used the following code (copied from the help):

Sub GetSelection()
    Dim objDatasheet As Object
    Dim lngFirstRow As Long, lngFirstColumn As Long


    Set objDatasheet = Screen.ActiveDatasheet
    lngFirstRow = objDatasheet.SelTop
    lngFirstColumn = objDatasheet.SelLeft
    MsgBox "The first item in this selection is located at " _
        & "Row " & lngFirstRow & ", Column " & lngFirstColumn

End Sub

Ok, that code works fine if i'm on a form which is in datasheet view, but if i use that form as a subform on another form which is "Single Form" view, i get the error message that there is no active datasheeet, although i'm operating on the subform, which is in datasheet view (the subform). Is it possible to fix that ?



0
 
LVL 54

Accepted Solution

by:
nico5038 earned 150 total points
ID: 6304623
In such a case the active control wo't be on the subform.
Use on the subform the field event "gotfocus" to place the controls name on the mainform with:
parent.txtActiveControl = me.activecontrol.name
Thus the last activated datasheet control is always available.

Nic;o)
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
In the article entitled Working with Objects – Part 1 (http://www.experts-exchange.com/Microsoft/Development/MS_Access/A_4942-Working-with-Objects-Part-1.html), you learned the basics of working with objects, properties, methods, and events. In Work…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now