Solved

Which cell i'm currently in ?

Posted on 2001-07-20
10
197 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
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 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
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 how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
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.

739 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