473,396 Members | 1,755 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

variable field

36
Hi all,

How can I store field name into a variable and then access its properties?

for example field text1

I'm trying something like this

dim box as string
box = "text1"
box.visible = true


I always get error
I even tried [box].visible and ["box"].visible but non works

thanks
Dec 23 '06 #1
6 2037
willakawill
1,646 1GB
Hi all,

How can I store field name into a variable and then access its properties?

for example field text1

I'm trying something like this

dim box as string
box = "text1"
box.visible = true


I always get error
I even tried [box].visible and ["box"].visible but non works

thanks
Hi. Nice try. The question is where do you want it to be visible?
If it is on a form in a label or textbox you will need to put one on your form and then reference it in your code.

Expand|Select|Wrap|Line Numbers
  1. textbox1.text = "text 1"
good luck
Dec 23 '06 #2
ADezii
8,834 Expert 8TB
Hi all,

How can I store field name into a variable and then access its properties?

for example field text1

I'm trying something like this

dim box as string
box = "text1"
box.visible = true


I always get error
I even tried [box].visible and ["box"].visible but non works
thanks
'Your syntax is incorrect, this will work:
Expand|Select|Wrap|Line Numbers
  1. Dim T As TextBox
  2.  
  3. Set T = Me![txtText]
  4. T.Visible = False
Dec 23 '06 #3
omozali
36
'Your syntax is incorrect, this will work:
Expand|Select|Wrap|Line Numbers
  1. Dim T As TextBox
  2.  
  3. Set T = Me![txtText]
  4. T.Visible = False
Thanks for everybody replies
Here is what I'm really trying to do

in a form there is option button 4 and option button 6
there are also 2 hidden text fields: text0 and text2
and a button

I want when ever an option button is checked and the button clicked then one of the textboxes would become visible depending which one is still invisible

so for example checking option button 4 would turn text0 visible coz its the first textbox that is invisible, then checking option button 6 would turn text2 visible unless text0 is still invisible (option 4 hasn;t been checked) then it would turn text0 visible.

checking any option button off would turn its corresponding textbox invisible when you click the button

this is my code that sucks, doesn't work


Private Sub Command10_Click()
Dim box As TextBox

Set box = findbox()

If Option4.Value = -1 Then
Dim option4box As TextBox
Set option4box = Me![box]
option4box.Visible = True
Else
Set option4box.Visible = False
End If

If Option6.Value = -1 Then
Dim option6box As TextBox
Set option6box = Me![box]
option6box.Visible = True
Else
Set option6box.Visible = False
End If

End Sub
-----------------------------------------------
Public Function findbox() As TextBox
If Text0.Visible = False Then
Set findbox = Me![Text0]
ElseIf Text2.Visible = False Then
Set findbox = Me![Text2]
Else
MsgBox "all boxes has been used"
End If
End Function
Dec 24 '06 #4
willakawill
1,646 1GB
Ok it is not nearly this difficult.

Expand|Select|Wrap|Line Numbers
  1. If Option4.Value Then
  2.    Text0.Visible = True
  3.    Text2.Visible = False
  4. Else
  5.    Text0.Visible = False
  6.    Text2.Visible = True
  7. End If
Dec 24 '06 #5
willakawill
1,646 1GB
BTW this code should be in the click event of your option frame. No need for a button:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Frame1_Click()
  2.     If Frame1.Value = -1 Then
  3.         Text0.Visible = True
  4.         Text2.Visible = False
  5.     Else
  6.         Text0.Visible = False
  7.         Text2.Visible = True
  8.     End If
  9. End Sub
Dec 24 '06 #6
NeoPa
32,556 Expert Mod 16PB
Try this :
Expand|Select|Wrap|Line Numbers
  1. Private Sub Frame1_Click()
  2.     Text0.Visible = Me.Frame1
  3.     Text2.Visible = Not Me.Frame1
  4. End Sub
Dec 28 '06 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Paul C-T | last post by:
I've read the newsgroups on this ... the PHP website and I'm still confused .... I am parsing a variable $howmany to a for / loop to print out multiple form fields with similar names ... for ($t...
1
by: Newbie | last post by:
OK, this may be impossible since I'm using 3rd party shopping cart ASP software, but I've been able to finagle a lot of other stuff I thought wouldn't work, so here we go: I'm using a form in...
9
by: Jack | last post by:
Hi, I got a asp form page where the POST ACTION = confirmation.asp page is used to save the values collected from text boxes from the form in a database. For example txtTotalOutlay field is being...
6
by: utterberg | last post by:
Hi, I've got an xml that looks like this: <section name="Risk"> <label>RISK MANAGEMENT (RM)</label> <field name="RM.1"> <ref>RM.1</ref> <label>Text goes here...</label> <option...
5
by: Colleyville Alan | last post by:
I have built a SQL statement that is trying to loop through the fields of a table that was built from a spreadsheet and hence is "short and fat". So rather than hard-coding, I have a loop from...
19
by: Skybuck Flying | last post by:
Hi, I think I might have just invented the variable bit cpu :) It works simply like this: Each "data bit" has a "meta data bit". The meta data bit describes if the bit is the ending bit...
2
by: Avi Laviad | last post by:
hi, sorry for the dumb question but how do i code a bit variable in c? i mean - shoudlnt the synax need to be: bit j; j = 1; correct me if im wrong (and i suppose i am). Avi.
9
by: Shapper | last post by:
Hello, I am declaring a variable in my aspx.vb code as follows: Public Class catalogue Public productid As String Private Sub Page_Load ... I have an image button where I call the...
16
by: Jonathan.Fillion | last post by:
Ok, I have a simple problem and I might just be blind and not see the (possibly simple) solution to it. I want to declare variables while adding them to a list simultaneously. What I want to do is...
3
by: mckbill | last post by:
Is there a way I can direct the cursor to a specific field (variable) in a form by typing the field name while in form view? I have a form with many fields, and it would be nice if there were...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.