controll if one or more records are changed...

User avatar
sal21
PlatinumLounger
Posts: 4355
Joined: 26 Apr 2010, 17:36

controll if one or more records are changed...

Post by sal21 »

I have 3 var, var1,var2,var3.
And in a table have field1, field2, field3.

I want to controll if one or more value in field are changed and make action code.

example:
var1=0
var2=1
var3=2

field1=0
field2=2
field3=2

in this case var2 is different of value in field2, make other action code.

I use the tipical .eof to loop in recordset.

User avatar
HansV
Administrator
Posts: 78488
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: controll if one or more records are changed...

Post by HansV »

The variables will have fixed values but the field values will change from record to record. Do you want to compare the field values to the same values of var1, var2 and var3 for ALL records?
Best wishes,
Hans

User avatar
sal21
PlatinumLounger
Posts: 4355
Joined: 26 Apr 2010, 17:36

Re: controll if one or more records are changed...

Post by sal21 »

HansV wrote:The variables will have fixed values but the field values will change from record to record. Do you want to compare the field values to the same values of var1, var2 and var3 for ALL records?
perfect!
One to one...
var1 is refered to field1, var2 is refered to field2...

User avatar
HansV
Administrator
Posts: 78488
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: controll if one or more records are changed...

Post by HansV »

With a recordset rst:

Code: Select all

Do While Not rst.EOF
  If rst!Field1 = var1 Then
    ' Do nothing
   Else
     MsgBox "Field1 is not equal to var1"
    ...
  End If
  If rst!Field2 = var2 Then
    ' Do nothing
   Else
     MsgBox "Field2 is not equal to var2"
    ...
  End If
  If rst!Field3 = var3 Then
    ' Do nothing
   Else
     MsgBox "Field3 is not equal to var3"
    ...
  End If
  rst.MoveNext
Loop
Best wishes,
Hans