HI Bruce, I'm really haveing a brain cramp.
How can I store the field [printab] from the tblconfig in to a number
value?
:
Thanks again Bruce. The dlookup was wrong. I guess I'm not using the
correct
commands.
What I need to do is get the value in the tblconfig field called
[printab]
It will be set to either 1 or 2
I just have to look at my programming to see how I did it before.
Thanks.
:
What happens when you compile the code? Did you assure that
frmBkBox
refers
to the subform *control*? The control and the form may have the
same
name,
depending on how you created the subform, but you can't be sure of
that
without checking.
Comment out the Timer code for now. I don't think it will work
anyhow,
at
least not as you intend. On the other hand I don't see anything
there
that
will cause an error.
Are you familiar with stepping through code? If not, here is the
procedure.
Open the VBA editor, go to the Load event code, and click the
vertical
bar
to the left of the code window next to the first line of code other
than Dim
.... . A dot should appear in the vertical bar, and the line of
code
wil be
highlighted. Run the code by attempting to open the form. The code
will
break (pause execution) at the highlighted line. Press the F8 key
to
step
through the code one line at a time. Highlighting will indicate the
current
line of code. Note which line causes the error (the error will
happen
when
you move past the offending line of code, not when you reach it).
While
stepping through the code you can point to variables, etc. to
determine
their values. For instance, after you move past the line:
bolPrintA = Nz(DLookup("[print]", "tblconfig"))
point to bolPrintA to see its value.
For various reasons I explained in my earlier reply your code almost
certainly will not work as you intend. You have moved the code to
the
Load
event, which is good, but it will not fix the code. You need to
address the
issues I raised.
Thanks Bruce. I did change the table field [print].
Here's what I did. I put the code in the On Load command in the
Main
Menu
form and tried it. I still got this error.
This is the error: "Method or data member not found"
I believe the error has to do with: Me.frmBkBox.Visible = False.
Because when I "rem" the statement then I get no errors. I've used
that
statement in other parts of the programs to hide sub-forms and it
worked.
Just not here.
May it be because of the flashing label I want?
Thanks again.
:
When something "gives you errors" you need to specify what errors
exactly.
I noticed a few things.
The Open event is too soon to check field values, as the
recordset
has
not
been loaded. The Load event may be the correct choice, but your
explanation
of what you are trying to do is a bit vague ("if certain criteria
is
met"),
so it is hard to know.
This is from VBA Help about DLookup:
"if you don't supply a value for criteria, the DLookup function
returns a
random value in the domain"
Assuming Print is a field in tblconfig, as it is your DLookup
expression
is
doing nothing more than looking for the presence of records in
tblconfig.
If there are records it returns a random value from the Print
field.
BTW,
Print is a reserved word, so it should not be used for a field
name.
http://www.accessmvp.com/JConrad/accessjunkie/resources.html#ReservedWords
Allen Browne's information is especially comprehensive and
helpful.
A properly constructed DLookup expression returns a field value.
If
Print
is a number field you can declare the DLookup result as an
integer,
but
it
isn't clear under what circumstances Print will be equal to 1.
The Nz function needs a "Value if null" argument. I think the
default is
an
empty string, which would not work as an integer.
To hide a subform you need to hide the subform control. Be sure
to
use
the
name for the "container" holding the subform.
Your Timer code does not contain a loop to increment the integer
that I
can
see, but let's get the DLookup working properly first.
message
Thanks for reading my post.
Here is the situation. I have two forms. Main Menu and
frmbkbox. I
want
the
bkbox sub form to unhide and flash a label if certain criteria
is
met.
The
problem is when I try to hide it using the On Open command it
gives me
errors
and still trys to flash the label on the sub form.
Here is the code
Dim bolPrintA As Integer
bolPrintA = Nz(DLookup("[print]", "tblconfig"))
If bolPrintA = 1 And Weekday(Now()) = 5 Then
MsgBox Weekday(Now())
MsgBox "box should be opened"
'Me.frmBkBox.Visible = True
Else
MsgBox "box should be closed"
Me.frmBkBox.Visible = False
End If
this is the error: Method or data member not found
This is what I have On Timer on the subform
Static intIterations As Integer
Me!Label0.Visible = Not Me!Label0.Visible
intIterations = intIterations + 1
If intIterations >= 10 Then
Me.TimerInterval = 0
intIterations = 0
Me!Label0.Visible = True
End If
Any help would be appreciated