Zero value currency control

anchamal

Registered User.
Local time
Today, 13:25
Joined
Mar 7, 2010
Messages
57
i have a currency control where the value is "0.00".
what is the if statement used to check if it's "0.00" to popup up a window.

i tried this code but nothing happens

If ITEMSQRYSALESSUB!PRICE1 = 0 Then
DoCmd.OpenForm "ZEROPRICEPOPUP"
Else:........

thanks
 
Try
If Me.YourControlName = 0 Then ....

You can test the value stored by using
Debug.Print "Value: " & Me.YourControlName

and pressing Ctrl-G to bring up the immediate window
 
still not working :(
 
So what was the result of your debug statement?
 
If you are talking about immediate, it's empty
nothing inside after i press ctrl+g
 
Did you add the debug.print statement before the IF ...
 
here is what i did:

Debug.Print "Value: " & Me.ITEMSQRYSALESSUB
If Me!ITEMSQRYSALESSUB!PRICE1 = 0 Or IsNull(ITEMSQRYSALESSUB!PRICE1) Then
DoCmd.OpenForm "ZEROPRICEPOPUP"
 
So in the immediate window you will have had
Value: something
If there was nothing in the something place then your value is null.

However the debug is printing one value - Me.ITEMSQRYSALESSUB
But your are then checking the value of something else - Me!ITEMSQRYSALESSUB!PRICE1
and then something else again ITEMSQRYSALESSUB!PRICE1

The red item doesn't match the purple or blue ones either ! You aren't printing out the value you are then comparing.
 
shoudl i change "value" with somethng else?

here is the code again

Debug.Print "Value: " & Me.ITEMSQRYSALESSUB
If Me.ITEMSQRYSALESSUB!PRICE1 = 0 Then
DoCmd.OpenForm "ZEROPRICEPOPUP"
 
Can you do the following please in your code
Debug.print "Value 1 - " & Me.ITEMSQRYSALESSUB
Debug.print "Value 2 - " & Me!ITEMSQRYSALESSUB!PRICE1
Debug.print "Value 3 - " & ITEMSQRYSALESSUB!PRICE1

Then tell us what each statement returns.
 
still nothing,

Debug.Print "Value 1 - " & Me.ITEMSQRYSALESSUB
Debug.Print "Value 2 - " & Me!ITEMSQRYSALESSUB!PRICE1
Debug.Print "Value 3 - " & ITEMSQRYSALESSUB!PRICE1

If Me.ITEMSQRYSALESSUB!PRICE1 = 0 Then
DoCmd.OpenForm "ZEROPRICEPOPUP"
Else:
Me.PROS = [ITEMSQRYSALESSUB]![PRICE1]
End If

what i did was to place my code in a second button just to see what happens
the code is working fine
 
the original code is in the after update event of a text box. so there code before and after
 
So in the immediate window you are getting nothing at all, but your code is now working ?
 
the code is working only in a new button i create for this purpose


strange thing is that if i place this code
If Me.ITEMSQRYSALESSUB!PRICE1 = 0 Or IsNull(ITEMSQRYSALESSUB!PRICE1) Then
DoCmd.OpenForm "ZEROPRICEPOPUP"


Else:
Me.PROS = [ITEMSQRYSALESSUB]![PRICE1]
End If

the second part if ITEMSQRYSALESSUB!PRICE1 is empty, it's working
but the first part no
 
Can you post up the entire code , from the Private Sub onward - you seem to be confusing field names/values with control names.

Also the way your code is written is wrong Else: would possibly be interpreted as a procedure label.

So please cut and paste it exactly as it is - no editing.
 
If [CUSTOMERNAMESEARCHFROMSALES2SUB]![PRICETYPE] = "PRICE1" Then

If Me.ITEMSQRYSALESSUB!PRICE1 = 0 Or IsNull(ITEMSQRYSALESSUB!PRICE1) Then
DoCmd.OpenForm "ZEROPRICEPOPUP"

Else:
Me.PROS = [ITEMSQRYSALESSUB]![PRICE1]
End If

ElseIf [CUSTOMERNAMESEARCHFROMSALES2SUB]![PRICETYPE] = "PRICE2" Then
If ITEMSQRYSALESSUB!PRICE2 = 0 Or IsNull(ITEMSQRYSALESSUB!PRICE2) Then
DoCmd.OpenForm "ZEROPRICEPOPUP"
Else:
Me.PROS = [ITEMSQRYSALESSUB]![PRICE2]
End If
ElseIf [CUSTOMERNAMESEARCHFROMSALES2SUB]![PRICETYPE] = "PRICE3" Then

If ITEMSQRYSALESSUB!PRICE3 = 0 Or IsNull(ITEMSQRYSALESSUB!PRICE3) Then
DoCmd.OpenForm "ZEROPRICEPOPUP"
Else:
Me.PROS = [ITEMSQRYSALESSUB]![PRICE3]
End If
ElseIf [CUSTOMERNAMESEARCHFROMSALES2SUB]![PRICETYPE] = "PRICE4" Then
If ITEMSQRYSALESSUB!PRICE4 = 0 Or IsNull(ITEMSQRYSALESSUB!PRICE4) Then
DoCmd.OpenForm "ZEROPRICEPOPUP"
Else:
Me.PROS = [ITEMSQRYSALESSUB]![PRICE4]
End If

ElseIf [CUSTOMERNAMESEARCHFROMSALES2SUB]![PRICETYPE] = "PRICE5" Then
If ITEMSQRYSALESSUB!PRICE5 = 0 Or IsNull(ITEMSQRYSALESSUB!PRICE5) Then
DoCmd.OpenForm "ZEROPRICEPOPUP"
Else:
Me.PROS = [ITEMSQRYSALESSUB]![PRICE5]
End If
End If
 
I needed all of the code including the beginning

Private Sub...

I want to know the name of the control for the after update.

The code you have posted is not very functional.
Put Option Explicit at the very top of the module underneath where it says Option Compare Database.
Press Debug and then select compile - it will highlight a host of issues.

Your If structures are off. I'll try and highlight those issues in another post.
 
Private Sub ITEMCODE_AfterUpdate()
Me.ITEMSQRYSALESSUB.Requery
Me.ITEMCODESAVER = Me.ITEMCODE

If Me.ITEMSQRYSALESSUB.Form.RecordsetClone.RecordCount = 0 Then
MsgBox "NO ITEM FOUND"
Me.ITEMCODE.SetFocus
Me.ITEMCODE = Null


Else:


If Me.onepass = True Then

If [ITEMSQRYSALESSUB]![PRICE1] = 0 And [CUSTOMERNAMESEARCHFROMSALES2SUB]![PRICETYPE] = "PRICE1" Then
Me.noedit = True
Me.QTY.SetFocus

ElseIf [ITEMSQRYSALESSUB]![PRICE2] = 0 And [CUSTOMERNAMESEARCHFROMSALES2SUB]![PRICETYPE] = "PRICE2" Then
Me.noedit = True
Me.QTY.SetFocus

ElseIf [ITEMSQRYSALESSUB]![PRICE3] = 0 And [CUSTOMERNAMESEARCHFROMSALES2SUB]![PRICETYPE] = "PRICE3" Then
Me.noedit = True
Me.QTY.SetFocus

ElseIf [ITEMSQRYSALESSUB]![PRICE4] = 0 And [CUSTOMERNAMESEARCHFROMSALES2SUB]![PRICETYPE] = "PRICE4" Then
Me.noedit = True
Me.QTY.SetFocus

ElseIf [ITEMSQRYSALESSUB]![PRICE5] = 0 And [CUSTOMERNAMESEARCHFROMSALES2SUB]![PRICETYPE] = "PRICE5" Then
Me.noedit = True
Me.QTY.SetFocus
Else:
Me.QTY = 1
If [CUSTOMERNAMESEARCHFROMSALES2SUB]![PRICETYPE] = "PRICE1" Then

If Me.ITEMSQRYSALESSUB!PRICE1 = 0 Or IsNull(ITEMSQRYSALESSUB!PRICE1) Then
DoCmd.OpenForm "ZEROPRICEPOPUP"

Else:
Me.PROS = [ITEMSQRYSALESSUB]![PRICE1]
End If




ElseIf [CUSTOMERNAMESEARCHFROMSALES2SUB]![PRICETYPE] = "PRICE2" Then
If ITEMSQRYSALESSUB!PRICE2 = 0 Or IsNull(ITEMSQRYSALESSUB!PRICE2) Then
DoCmd.OpenForm "ZEROPRICEPOPUP"
Else:
Me.PROS = [ITEMSQRYSALESSUB]![PRICE2]
End If
ElseIf [CUSTOMERNAMESEARCHFROMSALES2SUB]![PRICETYPE] = "PRICE3" Then

If ITEMSQRYSALESSUB!PRICE3 = 0 Or IsNull(ITEMSQRYSALESSUB!PRICE3) Then
DoCmd.OpenForm "ZEROPRICEPOPUP"
Else:
Me.PROS = [ITEMSQRYSALESSUB]![PRICE3]
End If
ElseIf [CUSTOMERNAMESEARCHFROMSALES2SUB]![PRICETYPE] = "PRICE4" Then
If ITEMSQRYSALESSUB!PRICE4 = 0 Or IsNull(ITEMSQRYSALESSUB!PRICE4) Then
DoCmd.OpenForm "ZEROPRICEPOPUP"
Else:
Me.PROS = [ITEMSQRYSALESSUB]![PRICE4]
End If

ElseIf [CUSTOMERNAMESEARCHFROMSALES2SUB]![PRICETYPE] = "PRICE5" Then
If ITEMSQRYSALESSUB!PRICE5 = 0 Or IsNull(ITEMSQRYSALESSUB!PRICE5) Then
DoCmd.OpenForm "ZEROPRICEPOPUP"
Else:
Me.PROS = [ITEMSQRYSALESSUB]![PRICE5]
End If
End If
Me.TOTAL = Me.QTY * Me.PROS
Me.VAT = Me.TOTAL * [VATRATELASTSUB]![LASTOFVATCALC]


Dim POINTOFSALES As DAO.Database

Dim UNIQUESALES As DAO.Recordset
Set POINTOFSALES = CurrentDb

Set rstUNIQUESALES = POINTOFSALES.OpenRecordset("UNIQUESALES")
rstUNIQUESALES.AddNew
rstUNIQUESALES("UNIQUE").Value = [UNIQUESALESQRYSUB]![LastOfUNIQUE] + 1

rstUNIQUESALES.Update
Me.UNIQUESALESQRYSUB.Requery
'-------------
Dim SALESDETAILS As DAO.Recordset
Set POINTOFSALES = CurrentDb

Set rstSALESDETAILS = POINTOFSALES.OpenRecordset("SALESDETAILS")
rstSALESDETAILS.AddNew
rstSALESDETAILS("SALESIDDD").Value = Me.SALESID
rstSALESDETAILS("ITEMCODE").Value = Me.ITEMCODE
rstSALESDETAILS("QTY").Value = Me.QTY
rstSALESDETAILS("APOTHIKES").Value = Me.APOTHIKES
rstSALESDETAILS("USERNAME").Value = Me.USERNAME
rstSALESDETAILS("SALESIDD").Value = Me.SALESID
rstSALESDETAILS("SALESTYPE").Value = "SALES"
rstSALESDETAILS("UNIQUE").Value = [UNIQUESALESQRYSUB]![LastOfUNIQUE]
rstSALESDETAILS("SALESINVOICE").Value = [UNIQUEINVOICENUMBERQRYSUB]![LastOfUNIQUEINVOICE]
rstSALESDETAILS("CUSTOMERNAME").Value = Me.CUSTOMERNAME
rstSALESDETAILS("TELEPHONE").Value = Me.TELEPHONE
rstSALESDETAILS("DESC").Value = "INV"
rstSALESDETAILS("PROS").Value = Me.PROS
rstSALESDETAILS("VAT").Value = Me.VAT
rstSALESDETAILS("TOTAL").Value = Me.TOTAL
rstSALESDETAILS("SALESDATE").Value = Date
rstSALESDETAILS("SALESTIME").Value = Time
rstSALESDETAILS("vat").Value = Me.VAT
If [CUSTOMERNAMESEARCHFROMSALES2SUB]![EARNPOINTS] = False Then
rstSALESDETAILS("POINTS").Value = 0
Else:
rstSALESDETAILS("POINTS").Value = Me.TOTAL
End If
rstSALESDETAILS("LOCALUNIQUESALES").Value = [LOCALUNIQUESALESQRysub]![LASTOFLOCALUNIQUESALES]

rstSALESDETAILS.Update

Me.UNIQUESALESQRYSUB.Requery

'_________________________________


Dim ITEMSSTOCK As DAO.Recordset
Set POINTOFSALES = CurrentDb

Set rstITEMSSTOCK = POINTOFSALES.OpenRecordset("ITEMSSTOCK")
rstITEMSSTOCK.AddNew
rstITEMSSTOCK("ITEMCODE").Value = Me.ITEMCODE
rstITEMSSTOCK("QTY").Value = (-Me.QTY)
rstITEMSSTOCK("APOTHIKES").Value = Me.APOTHIKES
rstITEMSSTOCK("UNIQUE").Value = [UNIQUESALESQRYSUB]![LastOfUNIQUE]
rstITEMSSTOCK("SALESTYPE").Value = "SALES"
rstITEMSSTOCK.Update

Me.ITEMSQRYSALESSUB.SetFocus


Me.SALESDETAILSQRYSUB.Requery



Me.PROS = Null
Me.VAT = Null
Me.TOTAL = Null
Me.QTY = Null
Me.ITEMCODE = Null
Me.ITEMCODE.SetFocus

End If
End If
End If
End Sub
 
Please use code tags (the # ) in the advanced editor. Your code with those and some indenting formatting is much easier to read;
Code:
Private Sub ITEMCODE_AfterUpdate()
    Me.ITEMSQRYSALESSUB.Requery
    Me.ITEMCODESAVER = Me.ITEMCODE

    If Me.ITEMSQRYSALESSUB.Form.RecordsetClone.RecordCount = 0 Then
        MsgBox "NO ITEM FOUND"
        Me.ITEMCODE.SetFocus
        Me.ITEMCODE = Null
    Else
        If Me.onepass = True Then

            If [ITEMSQRYSALESSUB]![PRICE1] = 0 And [CUSTOMERNAMESEARCHFROMSALES2SUB]![PRICETYPE] = "PRICE1" Then
                Me.noedit = True
                Me.Qty.SetFocus

            ElseIf [ITEMSQRYSALESSUB]![PRICE2] = 0 And [CUSTOMERNAMESEARCHFROMSALES2SUB]![PRICETYPE] = "PRICE2" Then
                Me.noedit = True
                Me.Qty.SetFocus

            ElseIf [ITEMSQRYSALESSUB]![PRICE3] = 0 And [CUSTOMERNAMESEARCHFROMSALES2SUB]![PRICETYPE] = "PRICE3" Then
                Me.noedit = True
                Me.Qty.SetFocus

            ElseIf [ITEMSQRYSALESSUB]![PRICE4] = 0 And [CUSTOMERNAMESEARCHFROMSALES2SUB]![PRICETYPE] = "PRICE4" Then
                Me.noedit = True
                Me.Qty.SetFocus

            ElseIf [ITEMSQRYSALESSUB]![PRICE5] = 0 And [CUSTOMERNAMESEARCHFROMSALES2SUB]![PRICETYPE] = "PRICE5" Then
                Me.noedit = True
                Me.Qty.SetFocus
            Else
                Me.Qty = 1
                If [CUSTOMERNAMESEARCHFROMSALES2SUB]![PRICETYPE] = "PRICE1" Then

                    If ITEMSQRYSALESSUB!PRICE1 = 0 Or IsNull(ITEMSQRYSALESSUB!PRICE1) Then
                        DoCmd.OpenForm "ZEROPRICEPOPUP"
                    Else
                        Me.PROS = [ITEMSQRYSALESSUB]![PRICE1]
                    End If

                ElseIf [CUSTOMERNAMESEARCHFROMSALES2SUB]![PRICETYPE] = "PRICE2" Then
                    If ITEMSQRYSALESSUB!PRICE2 = 0 Or IsNull(ITEMSQRYSALESSUB!PRICE2) Then
                        DoCmd.OpenForm "ZEROPRICEPOPUP"
                    Else
                        Me.PROS = [ITEMSQRYSALESSUB]![PRICE2]
                    End If
                ElseIf [CUSTOMERNAMESEARCHFROMSALES2SUB]![PRICETYPE] = "PRICE3" Then

                    If ITEMSQRYSALESSUB!PRICE3 = 0 Or IsNull(ITEMSQRYSALESSUB!PRICE3) Then
                        DoCmd.OpenForm "ZEROPRICEPOPUP"
                    Else
                        Me.PROS = [ITEMSQRYSALESSUB]![PRICE3]
                    End If
                ElseIf [CUSTOMERNAMESEARCHFROMSALES2SUB]![PRICETYPE] = "PRICE4" Then
                    If ITEMSQRYSALESSUB!PRICE4 = 0 Or IsNull(ITEMSQRYSALESSUB!PRICE4) Then
                        DoCmd.OpenForm "ZEROPRICEPOPUP"
                    Else
                        Me.PROS = [ITEMSQRYSALESSUB]![PRICE4]
                    End If

                ElseIf [CUSTOMERNAMESEARCHFROMSALES2SUB]![PRICETYPE] = "PRICE5" Then
                    If ITEMSQRYSALESSUB!PRICE5 = 0 Or IsNull(ITEMSQRYSALESSUB!PRICE5) Then
                        DoCmd.OpenForm "ZEROPRICEPOPUP"
                    Else
                        Me.PROS = [ITEMSQRYSALESSUB]![PRICE5]
                    End If
                End If
                Me.TOTAL = Me.Qty * Me.PROS
                Me.VAT = Me.TOTAL * [VATRATELASTSUB]![LASTOFVATCALC]


                Dim POINTOFSALES As DAO.Database

                Dim UNIQUESALES As DAO.Recordset
                Set POINTOFSALES = CurrentDb

                Set rstUNIQUESALES = POINTOFSALES.OpenRecordset("UNIQUESALES")
                rstUNIQUESALES.AddNew
                rstUNIQUESALES("UNIQUE").Value = [UNIQUESALESQRYSUB]![LastOfUNIQUE] + 1

                rstUNIQUESALES.Update
                Me.UNIQUESALESQRYSUB.Requery
                '-------------
                Dim SALESDETAILS As DAO.Recordset
                Set POINTOFSALES = CurrentDb

                Set rstSALESDETAILS = POINTOFSALES.OpenRecordset("SALESDETAILS")
                rstSALESDETAILS.AddNew
                rstSALESDETAILS("SALESIDDD").Value = Me.SALESID
                rstSALESDETAILS("ITEMCODE").Value = Me.ITEMCODE
                rstSALESDETAILS("QTY").Value = Me.Qty
                rstSALESDETAILS("APOTHIKES").Value = Me.APOTHIKES
                rstSALESDETAILS("USERNAME").Value = Me.username
                rstSALESDETAILS("SALESIDD").Value = Me.SALESID
                rstSALESDETAILS("SALESTYPE").Value = "SALES"
                rstSALESDETAILS("UNIQUE").Value = [UNIQUESALESQRYSUB]![LastOfUNIQUE]
                rstSALESDETAILS("SALESINVOICE").Value = [UNIQUEINVOICENUMBERQRYSUB]![LastOfUNIQUEINVOICE]
                rstSALESDETAILS("CUSTOMERNAME").Value = Me.CustomerName
                rstSALESDETAILS("TELEPHONE").Value = Me.TELEPHONE
                rstSALESDETAILS("DESC").Value = "INV"
                rstSALESDETAILS("PROS").Value = Me.PROS
                rstSALESDETAILS("VAT").Value = Me.VAT
                rstSALESDETAILS("TOTAL").Value = Me.TOTAL
                rstSALESDETAILS("SALESDATE").Value = Date
                rstSALESDETAILS("SALESTIME").Value = Time
                rstSALESDETAILS("vat").Value = Me.VAT
                If [CUSTOMERNAMESEARCHFROMSALES2SUB]![EARNPOINTS] = False Then
                    rstSALESDETAILS("POINTS").Value = 0
                Else
                    rstSALESDETAILS("POINTS").Value = Me.TOTAL
                End If
                rstSALESDETAILS("LOCALUNIQUESALES").Value = [LOCALUNIQUESALESQRysub]![LASTOFLOCALUNIQUESALES]

                rstSALESDETAILS.Update

                Me.UNIQUESALESQRYSUB.Requery

                '_________________________________

                Dim ITEMSSTOCK As DAO.Recordset
                Set POINTOFSALES = CurrentDb

                Set rstITEMSSTOCK = POINTOFSALES.OpenRecordset("ITEMSSTOCK")
                rstITEMSSTOCK.AddNew
                rstITEMSSTOCK("ITEMCODE").Value = Me.ITEMCODE
                rstITEMSSTOCK("QTY").Value = (-Me.Qty)
                rstITEMSSTOCK("APOTHIKES").Value = Me.APOTHIKES
                rstITEMSSTOCK("UNIQUE").Value = [UNIQUESALESQRYSUB]![LastOfUNIQUE]
                rstITEMSSTOCK("SALESTYPE").Value = "SALES"
                rstITEMSSTOCK.Update

                Me.ITEMSQRYSALESSUB.SetFocus
                
                Me.SALESDETAILSQRYSUB.Requery

                Me.PROS = Null
                Me.VAT = Null
                Me.TOTAL = Null
                Me.Qty = Null
                Me.ITEMCODE = Null
                Me.ITEMCODE.SetFocus

            End If
        End If
    End If
End Sub

I personally would use a Select Case so for just one section it would become;
Code:
    Dim iPopUp          As Boolean

    iPopUp = False

    Select Case [CUSTOMERNAMESEARCHFROMSALES2SUB]![PRICETYPE]

        Case "PRICE1"
            If ITEMSQRYSALESSUB!PRICE1 = 0 Or IsNull(ITEMSQRYSALESSUB!PRICE1) Then
                iPopUp = True
            Else
                Me.PROS = [ITEMSQRYSALESSUB]![PRICE1]
            End If
        Case "PRICE2"
            If ITEMSQRYSALESSUB!PRICE2 = 0 Or IsNull(ITEMSQRYSALESSUB!PRICE2) Then
                iPopUp = True
            Else
                Me.PROS = [ITEMSQRYSALESSUB]![PRICE2]
            End If
        Case "PRICE3"
            If ITEMSQRYSALESSUB!PRICE3 = 0 Or IsNull(ITEMSQRYSALESSUB!PRICE3) Then
                iPopUp = True
            Else
                Me.PROS = [ITEMSQRYSALESSUB]![PRICE3]
            End If
        Case "PRICE4"
           If ITEMSQRYSALESSUB!PRICE4 = 0 Or IsNull(ITEMSQRYSALESSUB!PRICE4) Then
                iPopUp = True
            Else
                Me.PROS = [ITEMSQRYSALESSUB]![PRICE4]
            End If
        Case "PRICE5"
            If ITEMSQRYSALESSUB!PRICE5 = 0 Or IsNull(ITEMSQRYSALESSUB!PRICE5) Then
                iPopUp = True
            Else
                Me.PROS = [ITEMSQRYSALESSUB]![PRICE5]
            End If
    End Select
    If iPopUp Then DoCmd.OpenForm "ZEROPRICEPOPUP"

It just makes it easier to follow. I am concerned that you have fields called Price1 , Price2, Price3 etc... This normally means badly stored data, and leads to the type of repeating code you are having to generate. I also think you may need to refer to the sub forms field controls as
Me!Subform1.Form!ControlName
where the red parts change to your forms names and controls.
 
Copied and pasted the corrected code, replaced the part which you said it would be better, but.... still the specific part isnot working :)
 

Users who are viewing this thread

Back
Top Bottom