Solved

msaccess putting fragmented strings to enabe a field object read

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

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

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

When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
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 Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …

770 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