Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

need help with statement 2

Status
Not open for further replies.

ggreg

Programmer
Mar 9, 2001
201
US
My problem lies in trying to get vba to check the field
name staffid#....I have try many variation on the line below
If IsNull "(qryckstaff.[staffid#])" Then

Button 14 is running a query to find out if fields are
null....to then disable buttons on the same form...this
form is only buttons...like the button that runs the query!

--------------------------------------
Private Sub Command14_Click()
On Error GoTo Err_Command14_Click

Dim stDocName As String

stDocName = "qryckstaff"
DoCmd.OpenQuery stDocName, acNormal, acEdit

Me!Command9.Enable = True
Else
Me!Command9.Enable = False
End If

Exit_Command14_Click:
Exit Sub
 
Hi, it looks to me like you IsNull is falling over because you are not checking against a record but perhaps a string value!
Code:
IsNull "(qryckstaff.[staffid#])"

You might try storing the record (ID) as a variable and then checking the state of the variable.

Code:
Dim varDummy as Variant

varDummy = Query!qryckstaff!staffid

If Isnull(varDummy) Then
  Me!Command9.Enable = True
Else
  Me!Command9.Enable = False
End If

But like I said, I think it's falling over with
Code:
IsNull "(qryckstaff.[staffid#])"
.
Maybe try:
Code:
IsNull(Query!qryckstaff!staffid)

birklea
 
Birklea,
try both ways but no luck
thanks abunch for trying,
...let me ask this....
if i take out the null question my query works find...
but if after i run that query what if wanted to look at
the fields of that query....maybe i need to due some
kind of recordset statements to set my buttons to
enable and disable....how would i write a recordset
statements??
 
Hi!

As long as there is only buttons on the form, just set the record source of the form to the query and then you can check any of the fields using Me!FieldName.

hth
Jeff Bridgham
bridgham@purdue.edu
 
Jeff did what you said about the set the record source....
now my code can find the field in the query......
but now it does not understand my buttons:
Me!Command9.Enable = True
Else
Me!Command9.Enable = False
End If

So what do I put in place of Me! to get the buttons to
Enable and disable????Can you help me out
 
Hi!

You shouldn't even need to use the Me! ButtonName.Enabled = False should be sufficient. Once you get the ButtonName. typed, Access should give you a list of options. If you don't get this list then check the spelling of the button's name.

hth
Jeff Bridgham
bridgham@purdue.edu
 
Jeff,

Finally after a couple of days, A Big Thanks to
you and some others!!!!!!!!!

I Got it to Work!---my last problem was i was mispelling
......Enabled

but i needed your other comments thanks again Jeff!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top