I have set up a procedure that checks the fields in a form and alerts you if a box has not been filled out and asks if you would like to complete the field. If you choose yes, it makes the textbox red and allows you to enter data in the text box.
I am having troubke getting the text box to return back to white after the field has been filled in. When this happens it also make the rest of the "same field in other records red as well. I only want the field that was not filled in to be red until the user enters something in it. Below is what I have done so far and it works other than it staying red. Can someone help me please?
For Each ctl In Me.Controls
If IsNull(ctl) Then
If ctl.Name <> "BreedSearch" Then
If ctl.Name <> "Breed Picture" Then
intResponse = MsgBox("A field has not been completed. Do you wish to complete the field?", vbYes + vbExclamation, "Missing Field")
If intResponse = vbYes Then
ctl.SetFocus
ctl.BackColor = 255
Exit Sub
End If
End If
End If
End If
Next ctl
DoCmd.GoToRecord , , acNext
End Sub
6 1281 - For Each ctl In Me.Controls
-
If IsNull(ctl) Then
-
If ctl.Name <> "BreedSearch" Then
-
If ctl.Name <> "Breed Picture" Then
-
intResponse = MsgBox("A field has not been completed. Do you wish to complete the field?", vbYes + vbExclamation, "Missing Field")
-
If intResponse = vbYes Then
-
ctl.SetFocus
-
ctl.BackColor = 255
-
Exit Sub
-
End If
-
End If
-
End If
-
End If
-
Next ctl
-
#### INSERT HERE ####
-
DoCmd.GoToRecord , , acNext
-
End Sub
-
Perhaps you could just set the background colour to normal at the point indicated?
By the way, one technique I have often used (in VB6, but may work in Access) is to place something in the .Tag property for each field you need to check, so your code can easily identify them. For example, rather than checking ctl.Name, you might do something like - if instr(ctl.Tag, "/NONULLS") Then
Then you just enter "/NONULLS" in the Tag property for any control you want this code to check. (Note, this also makes it easier to know which ones to change back to normal).
Thank you but what code do I need to put in there to get the colour back to normal? I am not familiar with the code to put the colour back to white or normal.
Thank you but what code do I need to put in there to get the colour back to normal? I am not familiar with the code to put the colour back to white or normal.
I wasn't thinking of anything complicated. Just ctl.BackColor = VbWhite, or whatever. I didn't know what you backcolor was, so didn't say.
Also, it might vary depending on the control type, plus you might need to check whether it is a control (or type of control) that you're interested in.
I wasn't thinking of anything complicated. Just ctl.BackColor = VbWhite, or whatever. I didn't know what you backcolor was, so didn't say.
Also, it might vary depending on the control type, plus you might need to check whether it is a control (or type of control) that you're interested in.
When I enter that I get an error.
Run time error 91
When I enter that I get an error.
Run time error 91
I don't recognise the error, but I'll take a stab in the dark - it's probably complaining because you're trying to change the backcolor property for a control that doesn't have one.
You might need to do it only for the relevant controls. As I said, there are various ways you can do this. Some examples: - If TypeOf <your control> Is TextBox Then ...
- If Instr(<your control>.Tag,"<some flag you placed there>") Then ...
- If <your control>.Name = <whatever you like> Then...
Oops! Since it refers to ctl, it would also need to go inside the For Each ctl loop. I would try this first. (What I just said in my post a couple of minutes ago still applies, though).
Sign in to post your reply or Sign up for a free account.
Similar topics
by: abcd |
last post by:
kutthaense Secretary Djetvedehald H. Rumsfeld legai predicted eventual
vicmadhlary in Iraq mariyu Afghmadhlaistmadhla, kaani jetvedehly after "a
ljetvedehg, hard slog," mariyu vede legai pressed...
|
by: Alex |
last post by:
Hi all,
I'm writing a small web application which searches a database based on
a date field, and populates a datagrid control with the results. The
datagrid control has selection buttons added...
|
by: Rahul |
last post by:
Hi Everybody
I have some problem in my script. please help me. This is script file.
I have one *.inq file. I want run this script in XML files. But this
script errors shows . If u want i am...
|
by: Tristán White |
last post by:
Hi
I am very new to PHP - actually, this is my second day at it, as I've only
recently started a new job last week. We're a charity.
I have a "No input file selected" problem. A Google search...
|
by: gunimpi |
last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431
********************************************************
VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help
wanted...
|
by: Jo |
last post by:
Hi there,
I'm Jo and it's the first time I've posted here. I'm in process of creating
a database at work and have come a little unstuck.....I'm a bit of a novice
and wondered if anyone could...
|
by: sorobor |
last post by:
dear sir ..
i am using cakephp freamwork ..By the way i m begener in php and javascript ..
My probs r bellow
I made a javascript calender ..there is a close button ..when i press close button...
|
by: thuythu |
last post by:
Please help me....
I used and Javascript to view the data. But when i click button open a popup windows, then select data and click save button. The popup close and return the main page, but the...
|
by: richard12345 |
last post by:
Hi Guys
I have problem with site I am building. The sidebar with menu and other thinks is overlapping footer. The footer move with the content and but it dos it dos not move with the sidebar. ...
|
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...
|
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...
|
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,...
|
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...
|
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: 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: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |