Command Button error

T

Tara

Not sure if this is the right place to post this, but
here goes! I have a form that has a combo box from which
users choose a family number. After this is done, the
choice they make limits the value in a text box called
Total IFSP's (this displays the total number of IFSP's
for that particular family). From there, a user can
enter an IFSP number into a third text box and then
view/edit that IFSP. There is also a comand button that
gives the user the option of adding a brand new IFSP for
that family. This all worked fine until recently, but
now when the user goes to add a new IFSP we are getting
an error message that says: Complie error: Syntax
Error. The code I have behind the Add IFSP command
button is:

Private Sub Command3_Click()
On Error GoTo Err_Command3_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "IFSP"
DoCmd.OpenForm stDocName, , , stLinkCriteria,
acFormAdd, , Me.Family_Number
IIf ([IFSP Number]=0,1,[IFSP Number]+1)

Exit_Command3_Click:
Exit Sub

Err_Command3_Click:
MsgBox Err.Description
Resume Exit_Command3_Click

End Sub

I get this error whether the family has had any previous
IFSP's or not. The user can still View/Edit any
previously entered IFSP's, just can't add any new ones.
Any ideas as to what's going on?
 
D

DebbieG

At a quick glance you are using stLinkCriteria in your DoCmd but it is not
defined.


| Not sure if this is the right place to post this, but
| here goes! I have a form that has a combo box from which
| users choose a family number. After this is done, the
| choice they make limits the value in a text box called
| Total IFSP's (this displays the total number of IFSP's
| for that particular family). From there, a user can
| enter an IFSP number into a third text box and then
| view/edit that IFSP. There is also a comand button that
| gives the user the option of adding a brand new IFSP for
| that family. This all worked fine until recently, but
| now when the user goes to add a new IFSP we are getting
| an error message that says: Complie error: Syntax
| Error. The code I have behind the Add IFSP command
| button is:
|
| Private Sub Command3_Click()
| On Error GoTo Err_Command3_Click
|
| Dim stDocName As String
| Dim stLinkCriteria As String
|
| stDocName = "IFSP"
| DoCmd.OpenForm stDocName, , , stLinkCriteria,
| acFormAdd, , Me.Family_Number
| IIf ([IFSP Number]=0,1,[IFSP Number]+1)
|
| Exit_Command3_Click:
| Exit Sub
|
| Err_Command3_Click:
| MsgBox Err.Description
| Resume Exit_Command3_Click
|
| End Sub
|
| I get this error whether the family has had any previous
| IFSP's or not. The user can still View/Edit any
| previously entered IFSP's, just can't add any new ones.
| Any ideas as to what's going on?
 
G

Guest

This line:
IIf ([IFSP Number]=0,1,[IFSP Number]+1)
-----Original Message-----
Which line is getting highlighted by the compile error?


Not sure if this is the right place to post this, but
here goes! I have a form that has a combo box from which
users choose a family number. After this is done, the
choice they make limits the value in a text box called
Total IFSP's (this displays the total number of IFSP's
for that particular family). From there, a user can
enter an IFSP number into a third text box and then
view/edit that IFSP. There is also a comand button that
gives the user the option of adding a brand new IFSP for
that family. This all worked fine until recently, but
now when the user goes to add a new IFSP we are getting
an error message that says: Complie error: Syntax
Error. The code I have behind the Add IFSP command
button is:

Private Sub Command3_Click()
On Error GoTo Err_Command3_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "IFSP"
DoCmd.OpenForm stDocName, , , stLinkCriteria,
acFormAdd, , Me.Family_Number
IIf ([IFSP Number]=0,1,[IFSP Number]+1)

Exit_Command3_Click:
Exit Sub

Err_Command3_Click:
MsgBox Err.Description
Resume Exit_Command3_Click

End Sub

I get this error whether the family has had any previous
IFSP's or not. The user can still View/Edit any
previously entered IFSP's, just can't add any new ones.
Any ideas as to what's going on?


.
 
R

Rob Oldfield

Yes. That line makes no sense. The iif function will return a value, but
you haven't told access what to do with it.

What is it supposed to be doing?


This line:
IIf ([IFSP Number]=0,1,[IFSP Number]+1)
-----Original Message-----
Which line is getting highlighted by the compile error?


Not sure if this is the right place to post this, but
here goes! I have a form that has a combo box from which
users choose a family number. After this is done, the
choice they make limits the value in a text box called
Total IFSP's (this displays the total number of IFSP's
for that particular family). From there, a user can
enter an IFSP number into a third text box and then
view/edit that IFSP. There is also a comand button that
gives the user the option of adding a brand new IFSP for
that family. This all worked fine until recently, but
now when the user goes to add a new IFSP we are getting
an error message that says: Complie error: Syntax
Error. The code I have behind the Add IFSP command
button is:

Private Sub Command3_Click()
On Error GoTo Err_Command3_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "IFSP"
DoCmd.OpenForm stDocName, , , stLinkCriteria,
acFormAdd, , Me.Family_Number
IIf ([IFSP Number]=0,1,[IFSP Number]+1)

Exit_Command3_Click:
Exit Sub

Err_Command3_Click:
MsgBox Err.Description
Resume Exit_Command3_Click

End Sub

I get this error whether the family has had any previous
IFSP's or not. The user can still View/Edit any
previously entered IFSP's, just can't add any new ones.
Any ideas as to what's going on?


.
 
G

Guest

It's supposed to add a new record in tblIFSP. I don't do
a lot of code stuff, but this worked before. Why not
now? I'm the only one messes with our databases here and
I actually designed this one, so I'm pretty sure nothing
has changed with it.

At any rate, I'm grateful for any help you can give me!
-----Original Message-----
Yes. That line makes no sense. The iif function will return a value, but
you haven't told access what to do with it.

What is it supposed to be doing?


This line:
IIf ([IFSP Number]=0,1,[IFSP Number]+1)
-----Original Message-----
Which line is getting highlighted by the compile error?


Not sure if this is the right place to post this, but
here goes! I have a form that has a combo box from which
users choose a family number. After this is done, the
choice they make limits the value in a text box called
Total IFSP's (this displays the total number of IFSP's
for that particular family). From there, a user can
enter an IFSP number into a third text box and then
view/edit that IFSP. There is also a comand button that
gives the user the option of adding a brand new IFSP for
that family. This all worked fine until recently, but
now when the user goes to add a new IFSP we are getting
an error message that says: Complie error: Syntax
Error. The code I have behind the Add IFSP command
button is:

Private Sub Command3_Click()
On Error GoTo Err_Command3_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "IFSP"
DoCmd.OpenForm stDocName, , , stLinkCriteria,
acFormAdd, , Me.Family_Number
IIf ([IFSP Number]=0,1,[IFSP Number]+1)

Exit_Command3_Click:
Exit Sub

Err_Command3_Click:
MsgBox Err.Description
Resume Exit_Command3_Click

End Sub

I get this error whether the family has had any previous
IFSP's or not. The user can still View/Edit any
previously entered IFSP's, just can't add any new ones.
Any ideas as to what's going on?


.


.
 
T

Tara

I just posted about this, but I don't think I was
completely clear, so let me try again. It is supposed to
add a new record to tblIFSP, then open up the form "IFSP"
where the user then enters data into the tblIFSP under
that family number and IFSP number.

Thanks again for any help!
-----Original Message-----
Yes. That line makes no sense. The iif function will return a value, but
you haven't told access what to do with it.

What is it supposed to be doing?


This line:
IIf ([IFSP Number]=0,1,[IFSP Number]+1)
-----Original Message-----
Which line is getting highlighted by the compile error?


Not sure if this is the right place to post this, but
here goes! I have a form that has a combo box from which
users choose a family number. After this is done, the
choice they make limits the value in a text box called
Total IFSP's (this displays the total number of IFSP's
for that particular family). From there, a user can
enter an IFSP number into a third text box and then
view/edit that IFSP. There is also a comand button that
gives the user the option of adding a brand new IFSP for
that family. This all worked fine until recently, but
now when the user goes to add a new IFSP we are getting
an error message that says: Complie error: Syntax
Error. The code I have behind the Add IFSP command
button is:

Private Sub Command3_Click()
On Error GoTo Err_Command3_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "IFSP"
DoCmd.OpenForm stDocName, , , stLinkCriteria,
acFormAdd, , Me.Family_Number
IIf ([IFSP Number]=0,1,[IFSP Number]+1)

Exit_Command3_Click:
Exit Sub

Err_Command3_Click:
MsgBox Err.Description
Resume Exit_Command3_Click

End Sub

I get this error whether the family has had any previous
IFSP's or not. The user can still View/Edit any
previously entered IFSP's, just can't add any new ones.
Any ideas as to what's going on?


.


.
 
R

Rob Oldfield

You mean that you're trying to pass both Me.Family_Number and the result of
the IIf to the opened form as OpenArgs? At the moment it looks from what
you've posted that you have...

docmd.openform ....
iif....

....as two separate lines. Which is why Access doesn't like it. The iif, on
its own, is never going to work.



Tara said:
I just posted about this, but I don't think I was
completely clear, so let me try again. It is supposed to
add a new record to tblIFSP, then open up the form "IFSP"
where the user then enters data into the tblIFSP under
that family number and IFSP number.

Thanks again for any help!
-----Original Message-----
Yes. That line makes no sense. The iif function will return a value, but
you haven't told access what to do with it.

What is it supposed to be doing?


This line:
IIf ([IFSP Number]=0,1,[IFSP Number]+1)

-----Original Message-----
Which line is getting highlighted by the compile error?


message
Not sure if this is the right place to post this, but
here goes! I have a form that has a combo box from
which
users choose a family number. After this is done, the
choice they make limits the value in a text box called
Total IFSP's (this displays the total number of IFSP's
for that particular family). From there, a user can
enter an IFSP number into a third text box and then
view/edit that IFSP. There is also a comand button
that
gives the user the option of adding a brand new IFSP
for
that family. This all worked fine until recently, but
now when the user goes to add a new IFSP we are getting
an error message that says: Complie error: Syntax
Error. The code I have behind the Add IFSP command
button is:

Private Sub Command3_Click()
On Error GoTo Err_Command3_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "IFSP"
DoCmd.OpenForm stDocName, , , stLinkCriteria,
acFormAdd, , Me.Family_Number
IIf ([IFSP Number]=0,1,[IFSP Number]+1)

Exit_Command3_Click:
Exit Sub

Err_Command3_Click:
MsgBox Err.Description
Resume Exit_Command3_Click

End Sub

I get this error whether the family has had any
previous
IFSP's or not. The user can still View/Edit any
previously entered IFSP's, just can't add any new ones.
Any ideas as to what's going on?


.


.
 
T

Tara

Yes! That's exactly what I'm trying to do. It's been a
long time since I've even looked at this particular
database, so I'm guessing that in the beginning the code
was a bit different that what is showing up now, although
I'm still not sure how it got changed. Any ideas on what
possibly changed and how to fix it? Like I said, I don't
work with code a lot and what I have used is just bits
and pieces I've picked up here and there, so I need a
little guidance I think!

Thanks! Tara
-----Original Message-----
You mean that you're trying to pass both
Me.Family_Number and the result of
the IIf to the opened form as OpenArgs? At the moment it looks from what
you've posted that you have...

docmd.openform ....
iif....

....as two separate lines. Which is why Access doesn't like it. The iif, on
its own, is never going to work.



I just posted about this, but I don't think I was
completely clear, so let me try again. It is supposed to
add a new record to tblIFSP, then open up the form "IFSP"
where the user then enters data into the tblIFSP under
that family number and IFSP number.

Thanks again for any help!
-----Original Message-----
Yes. That line makes no sense. The iif function will return a value, but
you haven't told access what to do with it.

What is it supposed to be doing?


This line:
IIf ([IFSP Number]=0,1,[IFSP Number]+1)

-----Original Message-----
Which line is getting highlighted by the compile error?


message
Not sure if this is the right place to post this, but
here goes! I have a form that has a combo box from
which
users choose a family number. After this is
done,
the
choice they make limits the value in a text box called
Total IFSP's (this displays the total number of IFSP's
for that particular family). From there, a user can
enter an IFSP number into a third text box and then
view/edit that IFSP. There is also a comand button
that
gives the user the option of adding a brand new IFSP
for
that family. This all worked fine until
recently,
but
now when the user goes to add a new IFSP we are getting
an error message that says: Complie error: Syntax
Error. The code I have behind the Add IFSP command
button is:

Private Sub Command3_Click()
On Error GoTo Err_Command3_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "IFSP"
DoCmd.OpenForm stDocName, , , stLinkCriteria,
acFormAdd, , Me.Family_Number
IIf ([IFSP Number]=0,1,[IFSP Number]+1)

Exit_Command3_Click:
Exit Sub

Err_Command3_Click:
MsgBox Err.Description
Resume Exit_Command3_Click

End Sub

I get this error whether the family has had any
previous
IFSP's or not. The user can still View/Edit any
previously entered IFSP's, just can't add any new ones.
Any ideas as to what's going on?


.



.


.
 
D

DebbieG

air code: Since TotalIFSP the total number of IFSP's for that particular
family

[IFSP Number] = IIf (Forms!OtherFormName!Total IFSP =
0,1,Forms!OtherFormName!Total IFSP + 1)
or
[IFSP Number] = IIf (isnull(Forms!OtherFormName!Total
IFSP),1,Forms!OtherFormName!Total IFSP + 1)

HTH,
Debbie



|I just posted about this, but I don't think I was
| completely clear, so let me try again. It is supposed to
| add a new record to tblIFSP, then open up the form "IFSP"
| where the user then enters data into the tblIFSP under
| that family number and IFSP number.
|
| Thanks again for any help!
|
| >-----Original Message-----
| >Yes. That line makes no sense. The iif function will
| return a value, but
| >you haven't told access what to do with it.
| >
| >What is it supposed to be doing?
| >
| >
| >| >> This line:
| >> IIf ([IFSP Number]=0,1,[IFSP Number]+1)
| >>
| >> >-----Original Message-----
| >> >Which line is getting highlighted by the compile
| error?
| >> >
| >> >
| >> message
| >> >| >> >> Not sure if this is the right place to post this,
| but
| >> >> here goes! I have a form that has a combo box from
| >> which
| >> >> users choose a family number. After this is done,
| the
| >> >> choice they make limits the value in a text box
| called
| >> >> Total IFSP's (this displays the total number of
| IFSP's
| >> >> for that particular family). From there, a user can
| >> >> enter an IFSP number into a third text box and then
| >> >> view/edit that IFSP. There is also a comand button
| >> that
| >> >> gives the user the option of adding a brand new IFSP
| >> for
| >> >> that family. This all worked fine until recently,
| but
| >> >> now when the user goes to add a new IFSP we are
| getting
| >> >> an error message that says: Complie error: Syntax
| >> >> Error. The code I have behind the Add IFSP command
| >> >> button is:
| >> >>
| >> >> Private Sub Command3_Click()
| >> >> On Error GoTo Err_Command3_Click
| >> >>
| >> >> Dim stDocName As String
| >> >> Dim stLinkCriteria As String
| >> >>
| >> >> stDocName = "IFSP"
| >> >> DoCmd.OpenForm stDocName, , , stLinkCriteria,
| >> >> acFormAdd, , Me.Family_Number
| >> >> IIf ([IFSP Number]=0,1,[IFSP Number]+1)
| >> >>
| >> >> Exit_Command3_Click:
| >> >> Exit Sub
| >> >>
| >> >> Err_Command3_Click:
| >> >> MsgBox Err.Description
| >> >> Resume Exit_Command3_Click
| >> >>
| >> >> End Sub
| >> >>
| >> >> I get this error whether the family has had any
| >> previous
| >> >> IFSP's or not. The user can still View/Edit any
| >> >> previously entered IFSP's, just can't add any new
| ones.
| >> >> Any ideas as to what's going on?
| >> >
| >> >
| >> >.
| >> >
| >
| >
| >.
| >
 
T

Tara

Just ignore that last post Rob! After some more thought
I realized what was wrong. I actually have code in
the "On Load" event of the IFSP form that is creating my
new IFSP number (not when the command button is clicked
as I said in the last post). Not sure how that IIf
statement got into the "On Click" event of the command
button, but once I figured out the problem and took it
out, it worked fine! So sorry for wasting your time, but
thank you so much. Every time I have a small issue like
this, I end up learning a little bit more just by working
through it with all of you on here!

Tara
-----Original Message-----
You mean that you're trying to pass both
Me.Family_Number and the result of
the IIf to the opened form as OpenArgs? At the moment it looks from what
you've posted that you have...

docmd.openform ....
iif....

....as two separate lines. Which is why Access doesn't like it. The iif, on
its own, is never going to work.



I just posted about this, but I don't think I was
completely clear, so let me try again. It is supposed to
add a new record to tblIFSP, then open up the form "IFSP"
where the user then enters data into the tblIFSP under
that family number and IFSP number.

Thanks again for any help!
-----Original Message-----
Yes. That line makes no sense. The iif function will return a value, but
you haven't told access what to do with it.

What is it supposed to be doing?


This line:
IIf ([IFSP Number]=0,1,[IFSP Number]+1)

-----Original Message-----
Which line is getting highlighted by the compile error?


message
Not sure if this is the right place to post this, but
here goes! I have a form that has a combo box from
which
users choose a family number. After this is
done,
the
choice they make limits the value in a text box called
Total IFSP's (this displays the total number of IFSP's
for that particular family). From there, a user can
enter an IFSP number into a third text box and then
view/edit that IFSP. There is also a comand button
that
gives the user the option of adding a brand new IFSP
for
that family. This all worked fine until
recently,
but
now when the user goes to add a new IFSP we are getting
an error message that says: Complie error: Syntax
Error. The code I have behind the Add IFSP command
button is:

Private Sub Command3_Click()
On Error GoTo Err_Command3_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "IFSP"
DoCmd.OpenForm stDocName, , , stLinkCriteria,
acFormAdd, , Me.Family_Number
IIf ([IFSP Number]=0,1,[IFSP Number]+1)

Exit_Command3_Click:
Exit Sub

Err_Command3_Click:
MsgBox Err.Description
Resume Exit_Command3_Click

End Sub

I get this error whether the family has had any
previous
IFSP's or not. The user can still View/Edit any
previously entered IFSP's, just can't add any new ones.
Any ideas as to what's going on?


.



.


.
 
R

Rob Oldfield

No problem. At a guess I'd say that someone accidentally pasted that chunk
of stuff in the click code...otherwise it would never have worked.

The fact that "It's been a long time since I've even looked at this
particular database" is a very good argument, by the way, for generous
commenting of code.


Tara said:
Just ignore that last post Rob! After some more thought
I realized what was wrong. I actually have code in
the "On Load" event of the IFSP form that is creating my
new IFSP number (not when the command button is clicked
as I said in the last post). Not sure how that IIf
statement got into the "On Click" event of the command
button, but once I figured out the problem and took it
out, it worked fine! So sorry for wasting your time, but
thank you so much. Every time I have a small issue like
this, I end up learning a little bit more just by working
through it with all of you on here!

Tara
-----Original Message-----
You mean that you're trying to pass both
Me.Family_Number and the result of
the IIf to the opened form as OpenArgs? At the moment it looks from what
you've posted that you have...

docmd.openform ....
iif....

....as two separate lines. Which is why Access doesn't like it. The iif, on
its own, is never going to work.



I just posted about this, but I don't think I was
completely clear, so let me try again. It is supposed to
add a new record to tblIFSP, then open up the form "IFSP"
where the user then enters data into the tblIFSP under
that family number and IFSP number.

Thanks again for any help!

-----Original Message-----
Yes. That line makes no sense. The iif function will
return a value, but
you haven't told access what to do with it.

What is it supposed to be doing?


This line:
IIf ([IFSP Number]=0,1,[IFSP Number]+1)

-----Original Message-----
Which line is getting highlighted by the compile
error?


message
Not sure if this is the right place to post this,
but
here goes! I have a form that has a combo box from
which
users choose a family number. After this is done,
the
choice they make limits the value in a text box
called
Total IFSP's (this displays the total number of
IFSP's
for that particular family). From there, a user can
enter an IFSP number into a third text box and then
view/edit that IFSP. There is also a comand button
that
gives the user the option of adding a brand new IFSP
for
that family. This all worked fine until recently,
but
now when the user goes to add a new IFSP we are
getting
an error message that says: Complie error: Syntax
Error. The code I have behind the Add IFSP command
button is:

Private Sub Command3_Click()
On Error GoTo Err_Command3_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "IFSP"
DoCmd.OpenForm stDocName, , , stLinkCriteria,
acFormAdd, , Me.Family_Number
IIf ([IFSP Number]=0,1,[IFSP Number]+1)

Exit_Command3_Click:
Exit Sub

Err_Command3_Click:
MsgBox Err.Description
Resume Exit_Command3_Click

End Sub

I get this error whether the family has had any
previous
IFSP's or not. The user can still View/Edit any
previously entered IFSP's, just can't add any new
ones.
Any ideas as to what's going on?


.



.


.
 

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

Similar Threads

Compile error: Syntax error 1
Pivot Tables: Please HElp! 1
Pivot Table print 2
findrecord in Access 2000 3
Object Required 3
Command Button help 4
'Like' in string 5
Command button in form 1

Top