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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need some help with "Else" code

Status
Not open for further replies.

RobertIngles

Technical User
Jan 20, 2011
113
CA
I apologize for my current lack of knowledge and hope that someone will be kind enough to give me some additional help.

I posted a question regarding "Record does not exist, open add record form". I have managed (with the help of PH) to have the add new user form open up if there is no matching userID record in the TBLUser (BTW Userid is text) however even if the user does exist the add new user form opens up. I think I need an "Else" statement "telling" the DB that if the user exists, just go to the next field. Here is the code I have that seems to work:

Private Sub Command118_Click()
'Create var.
Dim intChk As Integer

'This line counts the number of rec instances in TBLUser.
intChk = DCount("*", "TBLUser", "[UserID]" = "'" & Forms!FrmCreateNewLaptopProfileForBookings!UserID & "'")


'Does the rec exist? If not then open FRMCreateNewUserWhileBooking to add the new user details.
If intChk = 0 Then 'No?
DoCmd.OpenForm "FRMCreateNewUserWhileBooking", , , , acFormAdd


End If

End Sub

I think the Else statement should be something like:
Else
If intChk > 0 Then
SetFocus Me!Barcode

But I can't get it to work.
Many Many thanks for your help and patience with a newbie!!

Robert
 
If Then Else
Boolean wher if then is like yes no else give you some options.

If you wanted to find a number that greater than 60 then you can use if then. But if you wanted to add option to sort if greater than 50 but less than 60 you can add an else statement

Never give up never give in.

There are no short cuts to anything worth doing :)
 
In fact:
Me!Barcode.SetFocus

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top