Solved

msaccess putting fragmented strings to enabe a field object read

Posted on 2011-03-13
5
247 Views
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
0
Comment
Question by:sydneyguy
  • 4
5 Comments
 
LVL 84

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 500 total points
Comment Utility
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:

Forms(FormName).Controls(Controlname)

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

Author Comment

by:sydneyguy
Comment Utility
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
formtest1.zip
0
 

Author Comment

by:sydneyguy
Comment Utility
Data = Forms(sender).Controls("Check1").Value

allows me to get the data in reassembled format that works
0
 

Author Comment

by:sydneyguy
Comment Utility
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
' THIS IS THE FIRST PART I NEED TO GET GOING
' I KNOW THE FORM NAME AND I KNOW THE CONTROL NAME SO THE FORM
testval = "Check2"
Data1 = Forms(sender).Controls(testval).Value
MsgBox Data1
0
 

Author Closing Comment

by:sydneyguy
Comment Utility
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
gary
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

As with any other System Center product, the installation for the Authoring Tool can be quite a pain sometimes. This article serves to help you avoid making these mistakes and hopefully save you a ton of time on troubleshooting :)  Step 1: Make sur…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…

762 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

14 Experts available now in Live!

Get 1:1 Help Now