Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Are they the same or not?

Status
Not open for further replies.

RSX02

Programmer
May 15, 2003
467
CA
Hi
I have a problem. I would like to update a field in a dataset only when it's different to the value in the form.
I saw that it passed as if it was different. I put messages boxes to see if they were different but it seems like it's the same. Does somebody understand why it does this?

MsgBox("'" & dr.Item("Job_type") & "'") = 'Nothing'
MsgBox("'" & Me.JobType.SelectedValue & "'") = 'Nothing'
MsgBox(Len(dr.Item("Job_type"))) = 7
MsgBox(Len(Me.JobType.SelectedValue)) = 7
If Me.JobType.SelectedValue <> Nothing Then
If dr.Item("Job_type") <> Me.JobType.SelectedValue Then dr.Item("Job_type") = Me.JobType.SelectedValue
Else
If dr.Item("Job_type") <> "" Then dr.Item("Job_type") = ""
End If
 
yeah it's kind of that.
I want to create a new revision of a job only when changes has been done.
It detects the "haschange" properties as soon as I do an assignment even if both values are equal. This, I don't understand why...
that's why I put an if statement.
 
I still don't understand completely. Are you saying you start to edit a field, but then go back and decide not the change the original value?
 
No
I load my record. And, for the testing, i'm only trying to save (because if it has no change done I don't want to save it (create a new revision) but if it has changes I want to create a new revision). So as I didn't change anything between the Load record in my form and the save record. It has not supposed to change. But it seems like it has change and I don't know why...
Hope that make sense
 
I found how to resolve it:
Dim str1 As String
Dim str2 As String
str1 = Trim(dr.Item("Job_type"))
str2 = Trim(Me.JobType.SelectedValue)

If str1 <> str2 Then dr.Item("Job_type") = Me.JobType.SelectedValue

This is working.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top