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

Help with IF Greater Than

Status
Not open for further replies.

IJOC

Technical User
Jan 27, 2009
24
US
I am trying to provided an error check compent to my form where it checks to see if a value in the intWantQty is greater than 1 if so it would prompt the user of a possible error. However when I test the code below it prompts for and value enter even if the intWantQty is 0. Any ideas?

Thanks
-Pat


Private Sub intTradeUpdate_AfterUpdate()

Dim LResponse As Integer

LResponse = MsgBox("You are adding a card to the trade inventory," & Chr(13) & Chr(10) & "however it appears that you need this card to help complete complete this set" & Chr(13) & Chr(10) & "Do you wish to continue?", vbYesNo, "Continue")

If LResponse = vbYes Then
If intWantQty.Value >= 1 Then
strSQL = "Update tblCards set intTradeQty=intTradeQty+" & Nz(Me.intTradeUpdate, 0) & " where pkCardID= '" & Me.pkCardID & "'"
DoCmd.SetWarnings False
Debug.Print strSQL
DoCmd.RunSQL strSQL
strSQL = "Update tblCards set intTradeQty=intTradeQty+" & Nz(holdTIUpdqty, 0) & " where pkCardID= '" & Me.pkCardID & "'"
DoCmd.SetWarnings False
Debug.Print strSQL
DoCmd.RunSQL strSQL
Me.intWantQty.Requery
Me.intHaveQty.Requery
Me.intTradeQty.Requery
Me.intTradeUpdate.Value = ""
Else
Me.intTradeUpdate.Value = ""
Me.intWantQty.Requery
Me.intHaveQty.Requery
Me.intTradeQty.Requery
Me.intWantUpdate.SetFocus

End If
End If
 


Hi,

You have ONE prompt (MsgBox).

It is not controlled by any control structure.

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Skip thanks for the help. That made me think a bit different and this is what I came up with. It seems to work Do you see any problems if it.

strSQL = "Update tblCards set intTradeQty=intTradeQty+" & Nz(Me.intTradeUpdate, 0) & " where pkCardID= '" & Me.pkCardID & "'"
DoCmd.SetWarnings False
Debug.Print strSQL
DoCmd.RunSQL strSQL
strSQL = "Update tblCards set intTradeQty=intTradeQty+" & Nz(holdTIUpdqty, 0) & " where pkCardID= '" & Me.pkCardID & "'"
DoCmd.SetWarnings False
Debug.Print strSQL
DoCmd.RunSQL strSQL

If intWantQty.Value >= 1 Then
Dim LResponse As Integer

LResponse = MsgBox("You are adding a card to the trade inventory," & Chr(13) & Chr(10) & "however it appears that you need this card to help complete this set" & Chr(13) & Chr(10) & "Do you wish to continue?", vbYesNo, "Continue")

If LResponse = vbYes Then
Me.intWantQty.Requery
Me.intHaveQty.Requery
Me.intTradeQty.Requery
Me.intTradeUpdate.Value = ""
Else
strSQL = "Update tblCards set intTradeQty=intTradeQty-" & Nz(Me.intTradeUpdate, 0) & " where pkCardID= '" & Me.pkCardID & "'"
DoCmd.SetWarnings False
Debug.Print strSQL
DoCmd.RunSQL strSQL
strSQL = "Update tblCards set intTradeQty=intTradeQty-" & Nz(holdTIUpdqty, 0) & " where pkCardID= '" & Me.pkCardID & "'"
DoCmd.SetWarnings False
Debug.Print strSQL
DoCmd.RunSQL strSQL
Me.intWantQty.Requery
Me.intHaveQty.Requery
Me.intTradeQty.Requery
Me.intTradeUpdate.Value = ""
End If
End If

End Sub
 


Does it produce the results you want?

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top