help with simple if else command

DavidCantor

Registered User.
Local time
Today, 11:41
Joined
Oct 4, 2012
Messages
66
Private Sub Paid_Click()
Dim Vrbpaid As String
If [Paid] = True Then Vrbpaid = 1

ElseIf [Paid] = False Then Vrbpaid = 0
End If

[Paid] = Vrbpaid
End Sub


Can anyone tell me what the error is with this code?

I keep getting Else without If error message.
I have a check box Paid and I want to put a 1 for a true selection and a 0 for a false selection in the field.

thanks
 
Try this..
Code:
Private Sub Paid_Click()
    Dim Vrbpaid As String
    If [Paid] = True Then 
        Vrbpaid = 1
    ElseIf [Paid] = False Then 
        Vrbpaid = 0
    End If
    [Paid] = Vrbpaid
End Sub
 
Okay Sorry.. I did not read the question properly.. could you explain what you are trying to do?? The error you are recieving is because, if you use
Code:
If[COLOR=Red] condition [/COLOR]Then [COLOR=Red]statement[/COLOR]
it is a simplified If statement, which does not require a End If, since you have that syntax in your code, it will not recognize the Else that follows..
 
Last edited:
Thanks, i am not getting the error anymore but the code is not working. What was my error? was it just the layout of my code it didnt like?
 
Yes your code 'may' not work.. could you just explain what you want to do?
 
I am trying to change the value of a checked field from a y/n box from -1,0 to 1,0,
doesnt seem to be working
 
Guys

The way I read this it says If Paid = True Then Vrbpaid = 1/True, then Paid = Vrbpaid which is True.

So if Paid starts off as true it ends up true. If it starts off as false it ends up false.

Have a think about this as I think I am correct.
 
Rain, I guess you would have seen what David is trying to do.. He is trying to change the traditional -1 (True) to 1.. So David what is the DataType of the field on the table?
 
Try changing this

Dim Vrbpaid As String
to
Dim Vrbpaid As Boolean
 
David

Can you post a new Database with the Table and the form in question so that we can have a closer look.

Remove anything confidential.

Please post A2003 or earlier. Not 2007 or 2010
 
I am running 2010, sorry
I am trying to change the yn values of -1,0 to 1,0
 
I found something I have never used. So enter this as the Format.

;\1[Blue];0[Red]

Use a copy paste to get it right. Change the colours later.
 
David, Why do you want it to be 1 and 0? Since it is going to be in the table, does it really need that? You can do what you intend to do, but then you have to change the type to Integer. and the update all existing records with -1 to 1 and in Form view you have to write code to update the checkboxes based on the data in table... So is that really important?
 
I have Yes/No as the Data Type.

;\1[Blue];0[Red] as the Format in the General Tab.

And something which I missed, if you go to the Lookup Tab the Display Control must be "Text Box"
 
the tables are all empty, I have no data yet
I am designing a gui, and the requirements are for y=1 and n=0 as the data values.

Thanks for trying to help me
 
David, Why do you want it to be 1 and 0? Since it is going to be in the table, does it really need that? You can do what you intend to do, but then you have to change the type to Integer. and the update all existing records with -1 to 1 and in Form view you have to write code to update the checkboxes based on the data in table... So is that really important?

Paul

I think I have found the answer. See previous post. Could you please test it on your machine.
 
the tables are all empty, I have no data yet
I am designing a gui, and the requirements are for y=1 and n=0 as the data values.

Thanks for trying to help me

I hope that this does not mean that you are giving in.

We are almost there.
 

Users who are viewing this thread

Back
Top Bottom