code does not fall through IF statment for Yes/No fields

AshikHusein

Registered User.
Local time
Today, 12:39
Joined
Feb 7, 2003
Messages
147
Could anyone tell me waht is wrong with this code? It is not going through the IF statement even when the IF conditions are met.

For a brief explanation, the procedure is invoked when a button on a form "Comman26" is clicked.

After the button is clicked, the record set is opened and updated. "Debit Balance Cleared" and "Completed" are Yes/No fields.

The problem is that even if one of them has been check marked (on the form before the button is clicked) it does not go through the IF statement. Part of the code with the problem has been presented below.

Private Sub Command26_Click()
Dim db As Database
Dim rec As DAO.Recordset
Dim Count, counter1 As Integer
Dim TheUser As String
Application.SetOption "Default Record Locking", 2

On Error GoTo Error_Routine1

TheUser = fOSUserName

Set rec = Me.RecordsetClone

rec.Bookmark = Me.Bookmark





If (rec("Completed") = True) Or (rec("Debit Balance Cleared") = True) Then
MsgBox ("Yes")
rec.Edit
rec("UserCompleted") = TheUser
rec("UserCompleted_Date") = Now()
rec("UserCompleted_Count") = 1
rec("UserPending_Count") = 0
rec.Update
End If

Have bropken my head on this one but still cannot figure it out. Would appreciate help :confused:
 
I am not familiar with your use of the parenthesis. How about...

If rec("Completed") = -1 Or rec("Debit Balance Cleared") = -1 Then

I am used to seeing...

If [Completed] = -1 Or [Debit Balance Cleared] = -1 Then

Also, instead of using the fOSUserName use the environ function...

TheUser = Environ("UserName")
 
Last edited:
This also does not work:

If rec("Completed") = -1 Or rec("Debit Balance Cleared") = -1 Then...

The strange part is that if I use

If rec("Completed") = Yes Or rec("Debit Balance Cleared") = Yes Then...

it always falls through the loop without checking the conditions.
 
This is part of a multi_user database where records are searched using recordsets. The database is on the front end. It works for other similar instances for the same IF statments but does not work for this one.

Well I am still hammering away at it. Surely, there is something to the logic of it because it cant work in one instance and ont in the other. Appreciate your input.
 

Users who are viewing this thread

Back
Top Bottom