Solved

msaccess putting fragmented strings to enabe a field object read

Posted on 2011-03-13
5
249 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
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:

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

Author Comment

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

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

Author Comment

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

Featured Post

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

Suggested Solutions

This collection of functions covers all the normal rounding methods of just about any numeric value.
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
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…

789 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