hiding form

A

Afrosheen

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
 
B

BruceM

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.
 
A

Afrosheen

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.

BruceM said:
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.
Afrosheen said:
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
 
B

BruceM

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.

Afrosheen said:
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.

BruceM said:
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.
Afrosheen said:
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
 
A

Afrosheen

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.

BruceM said:
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.

Afrosheen said:
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.

BruceM said:
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.
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
 
A

Afrosheen

HI Bruce, I'm really haveing a brain cramp.
How can I store the field [printab] from the tblconfig in to a number value?


Afrosheen said:
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.

BruceM said:
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.

Afrosheen said:
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.
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
 
B

BruceM

You wrote:
"What I need to do is get the value in the tblconfig field called [printab]"

There are presumably many records. You need to get the value for the
Printab field from a particular record. Which one? It is as if you are
telling Access: "Get me the phone number from the Contacts table". Access
doesn't know which phone number you need, so it grabs one at random. You
have no way of knowing whose number it is unless you do some more digging.
If instead you say "Get me the phone number from the Contacts table from the
record in which the name field value is "Afrosheen", Access knows exactly
which phone number you seek (as long as there is just one "Afrosheen").

In answer to your most recent posting, what is Printab? I know it is a
field, and from what you have said its value is either 1 or 2. Since you
are using the Nz function I assume it can also be Null. You can get its
value using DLookup, but you need to tell Access more about the record in
which the value is to be found. If it is a number field you can assign its
value to an Integer variable. I think you could do that if it is a text
value, but in that case it would probably be best to use the CInt function:
bolPrintA = Nz(CInt(DLookup("[printab]", "tblconfig","[SomeField] = " &
Me.SomeField)),0)

You are telling access to find the value of Printab in tblconfig in which
the value of SomeField is the same as the value of SomeField in your form's
record source. That last part is the Where condition for DLookup, to which
I referred previously.

Afrosheen said:
HI Bruce, I'm really haveing a brain cramp.
How can I store the field [printab] from the tblconfig in to a number
value?


Afrosheen said:
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.

BruceM said:
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.
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
 
A

Afrosheen

Thanks again for your help.
The tblconfig is one record and one record only. I just get the information
from that record to do different things. For example.

On one form I have two commands. Adays and Bdays. What I do is when the form
loads it looks at the value of a field called "temp"in the tblconfig table.
Then I do a select case command.

case 1
enable the aday button

case 2
disable the bday button
end select

That's how I use the tblconfig table. I just thought I could look in the
tblconfig table and get the value of [printab] and set its value to a number
string.

If it can't be done then I'll have to abandon what I wanted to do.

I now understand about the dlookup. Thanks.

I hope I'm not being a pain. I'm just getting frustrated with this program.


BruceM said:
You wrote:
"What I need to do is get the value in the tblconfig field called [printab]"

There are presumably many records. You need to get the value for the
Printab field from a particular record. Which one? It is as if you are
telling Access: "Get me the phone number from the Contacts table". Access
doesn't know which phone number you need, so it grabs one at random. You
have no way of knowing whose number it is unless you do some more digging.
If instead you say "Get me the phone number from the Contacts table from the
record in which the name field value is "Afrosheen", Access knows exactly
which phone number you seek (as long as there is just one "Afrosheen").

In answer to your most recent posting, what is Printab? I know it is a
field, and from what you have said its value is either 1 or 2. Since you
are using the Nz function I assume it can also be Null. You can get its
value using DLookup, but you need to tell Access more about the record in
which the value is to be found. If it is a number field you can assign its
value to an Integer variable. I think you could do that if it is a text
value, but in that case it would probably be best to use the CInt function:
bolPrintA = Nz(CInt(DLookup("[printab]", "tblconfig","[SomeField] = " &
Me.SomeField)),0)

You are telling access to find the value of Printab in tblconfig in which
the value of SomeField is the same as the value of SomeField in your form's
record source. That last part is the Where condition for DLookup, to which
I referred previously.

Afrosheen said:
HI Bruce, I'm really haveing a brain cramp.
How can I store the field [printab] from the tblconfig in to a number
value?


Afrosheen said:
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.
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
 
B

BruceM

What happens when you compile the code? Have you tried stepping through the
code? If so, do you get a value for bolPrintA? Have you tried substituting
a number for the DLookup expression? That is, try: bolPrintA = 1 and see if
the code runs as expected.

I'm puzzled by the one-record tblConfig. I guess the values in the record
can change, which is why you use the table values rather than an actual
value (such as 1 or 2) in your code.

What you are trying to do can certainly be done. The problem is that the
code is not seeing the values you expect it to see. You will need to do
some troubleshooting.

BTW, this line of code:
'Me.frmBkBox.Visible = True
will not run because it has an apostrophe in front of it.

Please re-read the earlier posts. I have made several suggestions that you
may or may not have tried, and asked several more questions than you have
answered. I do not know if you have, for instance, verified the name of the
subform control, or if you have compiled or stepped through the code.
Assume there is a reason for all questions.

Afrosheen said:
Thanks again for your help.
The tblconfig is one record and one record only. I just get the
information
from that record to do different things. For example.

On one form I have two commands. Adays and Bdays. What I do is when the
form
loads it looks at the value of a field called "temp"in the tblconfig
table.
Then I do a select case command.

case 1
enable the aday button

case 2
disable the bday button
end select

That's how I use the tblconfig table. I just thought I could look in the
tblconfig table and get the value of [printab] and set its value to a
number
string.

If it can't be done then I'll have to abandon what I wanted to do.

I now understand about the dlookup. Thanks.

I hope I'm not being a pain. I'm just getting frustrated with this
program.


BruceM said:
You wrote:
"What I need to do is get the value in the tblconfig field called
[printab]"

There are presumably many records. You need to get the value for the
Printab field from a particular record. Which one? It is as if you are
telling Access: "Get me the phone number from the Contacts table".
Access
doesn't know which phone number you need, so it grabs one at random. You
have no way of knowing whose number it is unless you do some more
digging.
If instead you say "Get me the phone number from the Contacts table from
the
record in which the name field value is "Afrosheen", Access knows exactly
which phone number you seek (as long as there is just one "Afrosheen").

In answer to your most recent posting, what is Printab? I know it is a
field, and from what you have said its value is either 1 or 2. Since you
are using the Nz function I assume it can also be Null. You can get its
value using DLookup, but you need to tell Access more about the record in
which the value is to be found. If it is a number field you can assign
its
value to an Integer variable. I think you could do that if it is a text
value, but in that case it would probably be best to use the CInt
function:
bolPrintA = Nz(CInt(DLookup("[printab]", "tblconfig","[SomeField] = " &
Me.SomeField)),0)

You are telling access to find the value of Printab in tblconfig in which
the value of SomeField is the same as the value of SomeField in your
form's
record source. That last part is the Where condition for DLookup, to
which
I referred previously.

Afrosheen said:
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
 
A

Afrosheen

Hi Bruce, Sorry I'm getting back to you so late I just got home from work.
I did get the box to hide. Most of it was in the dlookup and part of it the
sub form had no name. So I corrected the two of them and it worked.

The 1 or 2 is just a number assigned to a command to be replaced by one or
the other then when I pull up another form it looks at the value of the field
and based on that number the form commands will either be active or deactive.
By the way when the program looks at the number I do use a dlookup and it
seems to work. Here is the code:

Private Sub Form_Open(Cancel As Integer)
Dim bolPrintA As Integer
bolPrintA = Nz(DLookup("[printab]", "tblconfig"))

20 Select Case bolPrintA
Case 1
30 A_Rotation.Enabled = True
40 bday_print.Enabled = False
50 Case 2
60 A_Rotation.Enabled = False
70 bday_print.Enabled = True
80 End Select

End Sub

Thanks also for showing me about the "dot" on the left hand side. I've
learned some thing new. I whish I knew about tricks like that before it would
have helped me from pulling what hair I have left out.

Thanks agin.
PS: I had to get rid of alot of that post. It was getting to long.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top