I searched the forums with no avail. I cant seem to figure out how to:
function somefunction(arg1, arg2)
If arg1 = "someText" OR "SomeOtherText" AND arg2 = 1 THEN
Run some code
else
Run some other code
end if
Not sure how to do this, I get errors anyway I try. I get errors with even
this:
If arg1 = "someText" OR "SomeOtherText" THEN
Run some code
else
Run other code
End if
Any help would be greatly appreciated. Thank you in advance
If arg1 = "someText" OR arg1 = "SomeOtherText" AND arg2 = 1 THEN
Note that you should include parentheses so it's obvious which you want:
If (arg1 = "someText" OR arg1 = "SomeOtherText") AND arg2 = 1 THEN
or
If arg1 = "someText" OR (arg1 = "SomeOtherText" AND arg2 = 1) THEN

Signature
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)
> I searched the forums with no avail. I cant seem to figure out how to:
> function somefunction(arg1, arg2)
[quoted text clipped - 12 lines]
> End if
> Any help would be greatly appreciated. Thank you in advance
Jerad - 18 Jan 2006 15:43 GMT
>If arg1 = "someText" OR arg1 = "SomeOtherText" AND arg2 = 1 THEN
>
>Note that you should include parentheses so it's obvious which you want:
>
>If (arg1 = "someText" OR arg1 = "SomeOtherText") AND arg2 = 1 THEN
Douglas,
Thanks for the response but I still get a "type mismatch" when using this
function in a query???
This is a simple SELECT query containing only 1 table
In my table, the field passed to Arg1 is set as "text" and the field passed
to arg2 is "number, Single"
I thought that usually "type mismatch" has to do with data type but i cant
seem to figure this out.
Thanks,
Jerad
Douglas J Steele - 18 Jan 2006 21:32 GMT
Try declaring the data types of your parameters in the function declaration:
function somefunction(arg1 As String, arg2 As Single)

Signature
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)
> >If arg1 = "someText" OR arg1 = "SomeOtherText" AND arg2 = 1 THEN
> >
[quoted text clipped - 12 lines]
> Thanks,
> Jerad
Jerad - 18 Jan 2006 22:00 GMT
>Try declaring the data types of your parameters in the function declaration:
>
>function somefunction(arg1 As String, arg2 As Single)
Thanks for the response, I declared the variables (probably good practice
anyway,
but recieved the same erros); heres what solved the problem in case anyone
else encounters the same thing.
function somefunction(arg1 as string, arg2 as single)
If (arg1 = "someText" And arg2 = 1) OR (Arg1 = "SomeOtherText" And arg2 = 1)
Then
run some code
else
run other code
end if
I gues I had to be more specific . Works now though, thanks for help guys
JK
Douglas J. Steele - 18 Jan 2006 22:48 GMT
>>Try declaring the data types of your parameters in the function
>>declaration:
[quoted text clipped - 15 lines]
> end if
> I gues I had to be more specific . Works now though, thanks for help guys
Glad you got it working, but what you ended up with should be the same as
If (arg1 = "someText" OR arg1 = "SomeOtherText") AND arg2 = 1 THEN
I suspect you must have mistyped something if that didn't work for you.

Signature
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)