Solved

Which cell i'm currently in ?

Posted on 2001-07-20
10
196 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

756 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