Uggh, another one of those crazy problems which I think would have a simple answer.
I have a query where one column of data (the field is called IssueNo) contains a number. I want to create another field in that query called OddEven which will display some text if the IssueNo number is an odd number and some other text if it is even. I believe this can be accomplished through use of a VBA public function in the query somehow (I know you can use VBA public functions for the criteria of a query at any rate). So, I came up with a quick public function trying to accomplish this. Here's the simple code:
Public Function OddChk(TheNumber) As Byte
If TheNumber And 1 Then
TheNumber = 1
Else
TheNumber = 0
End If
End Function
So, if you put in the field section of my query something like:
OddEvenChk: OddChk([IssueNo])
then I would THINK you would get back a 1 for the odd numbered issues and a 0 for the even numbered. But of course I don't get that, I only get zeros down the column.
Actually, it would be BETTER if I could have the function somehow return TRUE for the odd numbers and False for the even, but I can't figure out how to do that in the code. If I could, I would put something like this in the field column:
OddEvenChk: iif(OddChk([IssueNo] = True, "Odd", "Even")
Boy wouldn't that be nice.
Anyway, seems like this should be possible, or they should have created a function for this already. I saw an "IsOdd" workbook function in the help, but that didn't seem to work for me (Access just couldn't recognize the function).
Anyone have any ideas out there? I do appreciate any help that can be offered.
Thanks!!
I have a query where one column of data (the field is called IssueNo) contains a number. I want to create another field in that query called OddEven which will display some text if the IssueNo number is an odd number and some other text if it is even. I believe this can be accomplished through use of a VBA public function in the query somehow (I know you can use VBA public functions for the criteria of a query at any rate). So, I came up with a quick public function trying to accomplish this. Here's the simple code:
Public Function OddChk(TheNumber) As Byte
If TheNumber And 1 Then
TheNumber = 1
Else
TheNumber = 0
End If
End Function
So, if you put in the field section of my query something like:
OddEvenChk: OddChk([IssueNo])
then I would THINK you would get back a 1 for the odd numbered issues and a 0 for the even numbered. But of course I don't get that, I only get zeros down the column.
Actually, it would be BETTER if I could have the function somehow return TRUE for the odd numbers and False for the even, but I can't figure out how to do that in the code. If I could, I would put something like this in the field column:
OddEvenChk: iif(OddChk([IssueNo] = True, "Odd", "Even")
Boy wouldn't that be nice.
Anyway, seems like this should be possible, or they should have created a function for this already. I saw an "IsOdd" workbook function in the help, but that didn't seem to work for me (Access just couldn't recognize the function).
Anyone have any ideas out there? I do appreciate any help that can be offered.
Thanks!!