Results 1 to 5 of 5
  1. #1
    Dalagrath is offline Only a Man
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2010
    Location
    Colorado
    Posts
    45

    Else without If

    Code:
    'This is to determine whether or not the weapon hits the NPC2 target. If yes, it goes to Success, if no it goes to Fail.
    
    If Forms![frmBattleScreen]![NPC1ACWeap1Hit] <= Forms![frmBattleScreen]![NPC2subform]![EffectiveAC] Then GoTo NPC1Weap1Success
    
    ElseIf Forms![frmBattleScreen]![NPC1ACWeap1Hit] > Forms![frmBattleScreen]![NPC2subform]![EffectiveAC] Then GoTo NPC1Weap1Fail
    
    End If
    
    'If successful, it looks at the size of the opponent and then rolls and determines damage based upon that.
    NPC1Weap1Success:
    If Forms![frmBattleScreen]![NPC2subform]![SizeIDBOX] = 1 Or 3 Then
    
    NPC1Weap1Damage.Value = Int((Forms![frmBattleScreen]![NPC1subform]![MedSidesWeap1] - Forms![frmBattleScreen]![NPC1subform]![MedCountWeap1] + 1) * Rnd + Forms![frmBattleScreen]![NPC1subform]![MedCountWeap1]) + (Forms![frmBattleScreen]![NPC1subform]![DamageRACE1] + Forms![frmBattleScreen]![NPC1subform]![DamageSTR1] + Forms![frmBattleScreen]![NPC1subform]![DamageMAGIC1])
    
    ElseIf Forms![frmBattleScreen]![NPC2subform]![SizeIDBOX] = 2 Then
        
    NPC1Weap1Damage.Value = Int((Forms![frmBattleScreen]![NPC1subform]![LrgSidesWeap1] - Forms![frmBattleScreen]![NPC1subform]![LrgCountWeap1] + 1) * Rnd + Forms![frmBattleScreen]![NPC1subform]![LrgCountWeap1]) + (Forms![frmBattleScreen]![NPC1subform]![DamageRACE1] + Forms![frmBattleScreen]![NPC1subform]![DamageSTR1] + Forms![frmBattleScreen]![NPC1subform]![DamageMAGIC1])
    
    End If
    
    'If it fails to hit, it puts a "Miss" in the Damage box.
    NPC1Weap1Fail:
    [NPC1Weap1Damage] = "Miss"
    Keeps giving me the no Else without If error at line 5.

  2. #2
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    you have TWO 'if' statements and one closing END IF. wouldnt that be why?

  3. #3
    Dalagrath is offline Only a Man
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2010
    Location
    Colorado
    Posts
    45
    Sorry, I already fixed that before I posted. Same thing. Am I doing the "GoTo" commands correctly?

  4. #4
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    Quote Originally Posted by Dalagrath View Post
    Sorry, I already fixed that before I posted. Same thing. Am I doing the "GoTo" commands correctly?
    ummmm...all you need is "GOTO lineLableHere". looks like you have that, yes. As long as those redirects are to actual LABELS in your code. Otherwise it will error.

    and yes, you can write IF THEN statements on single lines although most programmers probably don't do it that way because it's harder to read and has to indentation to follow.

    you might also want to know that using GOTO statements is really not standard. maybe not 'as standard' as some. For all practical purposes, it's really only used "normally" in error handlers, along with the RESUME statement. both do essentially the same thing. I personally would ditch what you've got and replace them with CASE statements or nested IF statements. GOTO's are extremely tough to follow and maintain, especially if your procedures are long.

  5. #5
    Dalagrath is offline Only a Man
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2010
    Location
    Colorado
    Posts
    45
    Thank you, I just nested the If commands and it worked wonderfully.

Please reply to this thread with any new information or opinions.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums