473,396 Members | 1,921 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.

Wildcard Fields in VBA

Personally, my question seems to be what will be an easy fix, but I can't seem to find a solid answer on how to streamline my solution. I am using Access 2010 and I have a form with about 5 checkboxes. Each of the checkboxes, if ticked, will display a number of small images. Currently I am using the below if/else statement, but as you can imagine the statement becomes rather big due to the number of images being displayed. Is there a way to set a Me.BlueLight*.Visible statement instead of individually naming the images?

Expand|Select|Wrap|Line Numbers
  1. Private Sub chkBlueLight_AfterUpdate()
  2. If Me.chkBlueLight = True Then
  3.     Me.BlueLight01.Visible = True
  4.     Me.BlueLight02.Visible = True
  5.     Me.BlueLight03.Visible = True
  6.     etc...
  7.     Me.BlueLight27.Visible = True
  8. Else
  9.     Me.BlueLight01.Visible = False
  10.     Me.BlueLight02.Visible = False
  11.     Me.BlueLight03.Visible = False
  12.     etc...
  13.     Me.BlueLight27.Visible = False
  14. End If
  15. End Sub
  16.  
Mar 19 '16 #1

✓ answered by calaxan

is below code give you solution :

Expand|Select|Wrap|Line Numbers
  1.  Private Sub chkBlueLight_AfterUpdate()
  2. dim i as integer
  3. controlName = "BlueLight"
  4.  
  5. If Me.chkBlueLight = True Then  
  6.   for i=1 to 27 step 1
  7.     Me.Controls(controlName & Format(i, "00")).Visible = True
  8.   next i  
  9. Else
  10.   for i=1 to 27 step 1
  11.     Me.Controls(controlName & Format(i, "00")).Visible = False
  12.   next i
  13. End If
  14. End Sub
  15.  

3 1141
calaxan
12
is below code give you solution :

Expand|Select|Wrap|Line Numbers
  1.  Private Sub chkBlueLight_AfterUpdate()
  2. dim i as integer
  3. controlName = "BlueLight"
  4.  
  5. If Me.chkBlueLight = True Then  
  6.   for i=1 to 27 step 1
  7.     Me.Controls(controlName & Format(i, "00")).Visible = True
  8.   next i  
  9. Else
  10.   for i=1 to 27 step 1
  11.     Me.Controls(controlName & Format(i, "00")).Visible = False
  12.   next i
  13. End If
  14. End Sub
  15.  
Mar 19 '16 #2
Yes, thank you very much! Do you happen to know a good source where I can learn the basics of VBA? My experience in this matters are typically limited to the popular functions in Excel.
Mar 19 '16 #3
calaxan
12
To be honest my source is got from search engine :) . Find the correct keyword of my problem, then search the answer from search engine.
http://bytes.com also my reference if i have some difficulties.
And I think the tips from http://allenbrowne.com/tips.html can be your source too.
Mar 19 '16 #4

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

Similar topics

0
by: ParisTheDog | last post by:
I am trying to figure how to make a single select query in one table between two fields to see if they are similiar. I need the second one to have a wildcard. I can easily do this with no wildcard...
5
by: Robert Brown | last post by:
I have researched newsgroups and the web very thoroughly and unsuccessfully for a solution to what I believe is a very common problem. I know it's easy to do wildcard match against data in DB...
6
by: AAVF | last post by:
Hi We have a problem with a query. An Access database links via ODBC to a UNIX server. To speed things, we use the ODBC to load the relevant tables to the local PC that runs Access so that...
2
by: Keith | last post by:
A2003, XP Pro. I'm writing a VBA procedure to remove wildcard characters from a number of fields in various tables. I'm calling a sub routine and passing in strings representing the character...
3
by: george.lengel | last post by:
Hello experts, I have been struggling for days to solve this problem and every suggestion I find via Google does not work for me. There is probably a solution out there that will do what I want,...
7
by: eddie.holder | last post by:
Hi ladies and gents. I'm hoping anyone will be able to help me in a small access problem I am having. Let me try to explain: I have a form with textboxes which I use as criteria for a query. The...
2
by: googlegroups.dsbl | last post by:
I'm really confused here, and am wondering if someone knows what could be the issue with my TableAdapter query. A few months ago, I created a really neat program that has th ability to search by...
4
by: =?Utf-8?B?UmljaA==?= | last post by:
Is it possible to use a wildcard like feature with Dataview.Find? Actually, I tried that but did not get any rows. Is there some wildcard like feature of the dataview or some other object that I...
1
by: fungku | last post by:
Let's say I have a table. Let's say it is for fire hydrants. Let's say I have fields called: location_id1, location_id2, location_id3, etc... I have another table called location, with a...
0
by: savage678 | last post by:
Hi Everyone, I am new to this forum and am i dire need of some help. I am trying to use wildcard searches in infopath. I have it connected to an access database using data connection. I have...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.