I have a form that should a count of days exceed 25 a email should be sent out and then a box checked to acknowledge that it was sent out. I can get the first part but checking the box is causing me problems. Can anyone help? - Private Sub Form_Open(Cancel As Integer)
-
If (Forms!frmRetailProductionLogOpenSplit!RegBDays > 25 And Forms!frmRetailProductionLogOpenSplit!RegBComplianceNotified = 0) Then
-
DoCmd.SendObject acReport, "rptRetailProductionLogRegB", "PDFFormat(*.pdf)", "john.doe@bank.com", "", "", "Reg B", """Check the Reg B status on the attached Report"".", False, ""
-
Me!RegBComplianceNotified = 1
-
End If
-
-
End Sub
Assuming that control RegBComplianceNotified is a checkbox, you need to set it to the boolean value True (which is represented as -1, not 1), as follows: - Me!RegBComplianceNotified = True
or, equivalently, - Me!RegBComplianceNotified = -1
-Stewart
9 1777
Assuming that control RegBComplianceNotified is a checkbox, you need to set it to the boolean value True (which is represented as -1, not 1), as follows: - Me!RegBComplianceNotified = True
or, equivalently, - Me!RegBComplianceNotified = -1
-Stewart
I tried True and "Yes" and now have tried the -1 but I get the message "You can't assign a value to this object". If I run VBA to check the box by itself it works fine but not in combination.
NeoPa 32,556
Expert Mod 16PB HBCPH:
"You can't assign a value to this object".
Therein lies your problem then. What is it about the design of your form that precludes this control from accepting a value? We cannot tell you something that you haven't given us any clue to first.
I wish I knew the answer to that, as I mentioned if I run VBA to only check the box it works fine but if I try to add it to the VBA that sends the email it doesn't work. Separately they both will run. But I need them both to run if they meet the criteria.
Place line 4 before line 3
I've run into this error numerous times (though it was a long time ago, not working much with Access these days). As far as I can recall, I was basically unable to touch controls from my code unless they had the focus. So I had to set focus to the control, then set the value.
Might be worth a try, at least.
P.S. After reading "Place line 4 before line 3" (I had this page open for a few hours, so I didn't see that before posting my reply) I'm thinking it might just be that the right form has to have focus, not specifically the control.
Yes. This was the idea. Is this working ?
You could do a work around. Create an unbound text box hidden on your form. Then when the check box is clicked set the text box value to 1 or True or what ever you want. Then have your code check the hidden text box for the value instead of the check box itself for the value and see if that works. After the email is sent then clear the text box of the value.
I finally got it to run, it seems to have something to do with which event triggered the VBA. I moved it to "On Lod" and it ran fine. Thank You to everyone for trying to help.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Brian Jorgenson |
last post by:
Is it possible to add a If-then statement in a query? For example, If
field B is greater then field A, then field B = something else.
I am creating a class schedule. My class size's are 5 people...
|
by: sck10 |
last post by:
Hello,
I am trying to use an If Then statement inside of a repeater control.
However, I am getting the following error:
Expression expected.
Any help would be appreciated.
Thanks in...
|
by: jburris |
last post by:
I am completely new to VBA. I am trying to update a yes/no box in a
subform based on a value that I call from the main form into the
subform. Below is the if /then statement i am using:
If...
|
by: Etayki |
last post by:
Hello,
I am trying to create an IF statement that will recognize whether or
not a field in the database table is set to some value or if is NULL.
Dim myCommand As New...
|
by: akirekab |
last post by:
I have a field called PA on a form. The table property is Requred = yes
At run time I want to change it based on certain other criteria, to Required = No
on Before Update of either the control or...
|
by: mckurban |
last post by:
Hi All,
I'm not very familiar with Javascript and need help with setting up some javascript code to allow users to create dynamic radio buttons from text field and then to use selected radio value...
|
by: Shortstuff12345 |
last post by:
I'm trying to use VBA code to disable a field based on the value of another field in a form. The code I have properly updates the enabled property of the field when it changes; however, it changes...
|
by: curious80237 |
last post by:
In Access 2003: A table with four yes/no fields is part of a query used as data source for a report. The yes/no fields show in the datasheet and the report as checkboxes; the default value of the...
|
by: JasonWinchester |
last post by:
Hi, all
I'm having trouble figuring out how to use an if-then statement to check whether or not a variable is pointing to a look-up column.
What I have is a form that contains a combobox and a...
|
by: kent christensen |
last post by:
Im trying to create an if then statement in the expression builder. I have a query that has 2 Columns that have currency values in them.
I want to set up a new column that basically uses the...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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: 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,...
|
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...
| |