I can't seem to get the Syntax right on IF, ELSE , End If. HELP........
Command Button 'Finished'
If frmUpdateAcctList.Desc Is <> "" Then
MsgBox "The Account List is Updated"
Docmd.Requery
Docmd.Close
If frmUpdateAcctList.Desc Is = "" Then
MsgBox "The Account Descriptions are Not Updated, Do you want to Update the
Account List Later", vbCancel,Yes
If Cancel, then return to the form
If Yes, msgbox "You will be asked to Update the Account List at a Later
time"vbOK
docmd.query (for the items that were updated)
docmd.close
Klatuu - 23 Feb 2006 18:48 GMT
The If Then Else End If construct is not that difficult. A Then is required
for every If. An End If is always required for every If. The Else is
optional.
If SomeCondition = True Then
Take Actions provided the condition evaluates to True
Else
Take Actions provided the condition does not evaluate to True
End If
I have modifed your code to give you a real life example. Please notice
the indentation. It makes conditional statements much easier to read.
If frmUpdateAcctList.Desc = "" Then
If MsgBox("The Account Descriptions are Not Updated, " _
& "Do you want to Update the Account List Later", _
vbQuestion + vbYesNo) = vbYes Then
msgbox "You will be asked to Update the Account List at a Later time"
Docmd.Close
'The Line below is not correct. I don't know what you are trying to do here
Else
docmd.query (for the items that were updated)
End If
Else
MsgBox "The Account List is Updated"
Docmd.Requery
End If
> I can't seem to get the Syntax right on IF, ELSE , End If. HELP........
>
[quoted text clipped - 15 lines]
> docmd.query (for the items that were updated)
> docmd.close
George Nicholson - 23 Feb 2006 19:32 GMT
Dim iResponse as Integer
Dim strMessage as String
If frmUpdateAcctList.Desc <> "" Then
MsgBox "The Account List is Updated"
Docmd.Requery
Docmd.Close
Else
'(If frmUpdateAcctList.Desc = "" )
strMessage = "The Account Descriptions are Not Updated, Do you want to
Update the Account List Later"
iResponse = MsgBox (strMessage, vbYesNo)
' Begin 2nd nested If...Then structure. This statement completed (End
If) before you complete the current/first If...Then.
If iResponse = vbNo Then
' Return to the form: i.e., do nothing
Else
' Yes
strMessage = "You will be asked to Update the Account List at a
Later time"
Msgbox strMessage, vbOK
docmd.query (for the items that were updated)
docmd.close
End If 'if iResponse = vbNo Then
End If 'If frmUpdateAcctList.Desc <> "" Then
HTH,

Signature
George Nicholson
Remove 'Junk' from return address.
>I can't seem to get the Syntax right on IF, ELSE , End If. HELP........
>
[quoted text clipped - 16 lines]
> docmd.query (for the items that were updated)
> docmd.close
fredg - 23 Feb 2006 19:44 GMT
> I can't seem to get the Syntax right on IF, ELSE , End If. HELP........
>
[quoted text clipped - 15 lines]
> docmd.query (for the items that were updated)
> docmd.close
In addition to your other replies, Desc is a reserved Access/VBA/Jet
word and should not be used as a field or control name.
For additional reserved words, see the Microsoft KnowledgeBase article
for your version of Access:
109312 'Reserved Words in Microsoft Access' for Access 97
209187 'ACC2000: Reserved Words in Microsoft Access'
286335 'ACC2002: Reserved Words in Microsoft Access'
321266 'ACC2002: Microsoft Jet 4.0 Reserved Words'

Signature
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
Klatuu - 23 Feb 2006 19:51 GMT
If you use good naming conventions, you don't have to know or care what the
reserved words are.
> > I can't seem to get the Syntax right on IF, ELSE , End If. HELP........
> >
[quoted text clipped - 25 lines]
> 286335 'ACC2002: Reserved Words in Microsoft Access'
> 321266 'ACC2002: Microsoft Jet 4.0 Reserved Words'