?
Solved

Which cell i'm currently in ?

Posted on 2001-07-20
10
Medium Priority
?
199 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
How Blockchain Is Impacting Every Industry

Blockchain expert Alex Tapscott talks to Acronis VP Frank Jablonski about this revolutionary technology and how it's making inroads into other industries and facets of everyday life.

 
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
 
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 450 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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
Suggested Courses

777 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