msaccess putting fragmented strings to enabe a field object read

Posted on 2011-03-13
Last Modified: 2012-05-11
in access from a form i need to pass the form name ie Forms![Questions2:2]  as well as the object name that is clicked ie  "2:1:1"  whcih woudl be a slect box id name anb then put it back together as in Forms![Questions2:2]![2:2:1].Value. which i can use to find the value of. this is the one line as you would use to find the value of the object.

so then i could find the value as in msgbox(Forms![Questions2:2]![2:2:1].Value)
which would then diisplay the value of the check box.
i have so many check boxes that i just want to call using the place that it omes from ie
"Forms![Questions2:2]" and the object name ie  "2:2:1" put it back together and be able to use
MsgBox (Forms![Questions2:2]![2:2:1:2].Value)

or as the entire line is deliver as in  
call findval("Forms![Questions2:2]![2:2:1:2].Value")  
how would i strip the " away and then be able to use
data = Forms![Questions2:2]![2:2:1:2].Value  to find the value

Private Sub Ctl2_2_1_1_Click()
    MsgBox Forms![Questions2:2]![2:2:1:2].Value
End Sub
Question by:sydneyguy
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
LVL 84

Accepted Solution

Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 500 total points
ID: 35127176
I'm not exactly sure what you're asking, but Access provides the ActiveControl method and the PreviousControl method. The Form name is simply Me.Name, so if you need to pass that information to a function named SetMyValue:

Function SetMyValue(FormName as String, ControlName As String)
  <function code here>
End Function

You'd call it like this:

SetMyValue Me.Name, Screen.PreviousControl.Name

Once there, you can refer to the form's control like this:


However, I may have misunderstood this question, since it's somewhat vague. If so, please clarify exactly what you're trying to do and we'll see if we can help.

Author Comment

ID: 35153045
have tried what you suggested with no luck so to give a better idea of what is happening i built a small db with the first part of the problem set up in side
just go the the only form that is there sender and click the first tick box and the debug will crash on the code that i am having trouble with.
once it gets here what i am doing is using this chkbox name to pull back from a data base a grouping that this check box is part of, then i retrive the other names that are also in that group and then use this data to then refer back to the form to check the other values  that have been returned and access what they are set to.
i have some notes listed on the data page were the line crashes to make life easy for you
thanks for your help
just open the sender form and click the first check box

Author Comment

ID: 35153063
Data = Forms(sender).Controls("Check1").Value

allows me to get the data in reassembled format that works

Author Comment

ID: 35153078
ok so this code seems to be working now, i can now extract any code i want from the first call routine

Data = Forms(sender).Controls("Check1").Value
testval = "Check2"
Data1 = Forms(sender).Controls(testval).Value
MsgBox Data1

Author Closing Comment

ID: 35153284
ok thats works for and have tried it in the module call and allows me to access, now all i have to do is to extract the data from the pages from the data base and that looks to be working as well, so at present it seems to be doing what i am asking of it
so thanks again for your all your help and effort ,most appreciated

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

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

Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
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.
The viewer will learn how to simulate a series of coin tosses with the rand() function and learn how to make these “tosses” depend on a predetermined probability. Flipping Coins in Excel: Enter =RAND() into cell A2: Recalculate the random variable…

726 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