Solved

Which cell i'm currently in ?

Posted on 2001-07-20
10
192 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
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 
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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

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…
Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
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…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …

920 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

11 Experts available now in Live!

Get 1:1 Help Now