Records Not getting updated (1 Viewer)

sbaud2003

Member
Local time
Today, 10:02
Joined
Apr 5, 2020
Messages
178
Hi Sir/Madam
I am usimg the forlloing SQL, but the records are not updating.


UPDATE MEMBERS SET MEMBERS.EL = [EL]+(DateDiff("d",[FORMS]![EMPLOYEE_LEAVE_MASTER]![TXTFROM],[FORMS]![EMPLOYEE_LEAVE_MASTER]![TXTTO])+1)
WHERE ((([FORMS]![EMPLOYEE_LEAVE_MASTER]![TXLV])="EL") AND ((MEMBERS.ACCOUNT_NO)=[FORMS]![EMPLOYEE_LEAVE_MASTER]![TXTAC]));


can you help me.
 
Last edited:

Minty

AWF VIP
Local time
Today, 05:32
Joined
Jul 26, 2013
Messages
10,371
If you convert that to a select query does it select any records?

How are you running this query, is it a saved query run from a command?
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Yesterday, 23:32
Joined
Feb 28, 2001
Messages
27,189
My initial question is the data type of the fields represented in [Forms]![EMPLOYEE_LEAVE_MASTER]![TXTFROM] and [Forms]!...![TXTTO], which you are using in a context where they MUST be of DATE data type.

Further, your WHERE clause has field [TXTAC] used with syntax that would make a difference if their data types were not the same. (Either both string or both numeric would work; mixed format - would not.)

Minty's question also is important, and his "text by converting it to a SELECT" question is related to my second comment.
 

sbaud2003

Member
Local time
Today, 10:02
Joined
Apr 5, 2020
Messages
178
My initial question is the data type of the fields represented in [Forms]![EMPLOYEE_LEAVE_MASTER]![TXTFROM] and [Forms]!...![TXTTO], which you are using in a context where they MUST be of DATE data type.

Further, your WHERE clause has field [TXTAC] used with syntax that would make a difference if their data types were not the same. (Either both string or both numeric would work; mixed format - would not.)

Minty's question also is important, and his "text by converting it to a SELECT" question is related to my second comment.
[Forms]![EMPLOYEE_LEAVE_MASTER]![TXTFROM] and [Forms]!...![TXTTO] are date type and TXTAC is a numeric.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 12:32
Joined
May 7, 2009
Messages
19,245
why do you need to add Form variable to your query:

[FORMS]![EMPLOYEE_LEAVE_MASTER]![TXLV]="EL"

use code to do this:

Code:
Dim diff As Integer, sql As String
If [FORMS]![EMPLOYEE_LEAVE_MASTER]![TXLV] & "" = "EL" Then
    diff = DateDiff("d", [FORMS]![EMPLOYEE_LEAVE_MASTER]![TXTFROM],[FORMS]![EMPLOYEE_LEAVE_MASTER]![TXTTO])+1" 
    sql = "UPDATE MEMBERS SET [EL] = Nz([EL], 0) + " & diff & " Where MEMBERS.ACCOUNT_NO='" & [FORMS]![EMPLOYEE_LEAVE_MASTER]![TXTAC] & "'"
    currentdb.Execute sql, dbFailOnError
End If
End If
 

Users who are viewing this thread

Top Bottom