comparison and get the result

G

Guest

Below is Programming code for get the result( Statusitem) for camparison
item1 between item2( if item1 = item2,means "ok" then "not"). This output
must be fill in status item field(column). This problem is wrong code for get
the result.Any body can help me to correct that code prgramming.

Private Sub GenerateClick()
Dim dbs As Database, rst As Recordset
Dim strSelect As String

Dim IT1 As TextBox, IT2 As TextBox, St As String

Set dbs = CurrentDb

strSelect = "SELECT * FROM P1ENTRY"

Set rst = dbs.OpenRecordset(strSelect)

IT1 = rst(Item1)
IT2 = rst(Item2)


rst.MoveNext
If (Item1 = Item2) Then
StatusItem = "ok"
Else
StatusItem = "not ok"
rst.Close
End If
End Sub
 
G

Guest

Hi hisham
if item1 and item2 are two field on a form and statusitem is a third field
on the same form there's no need to create a recordset. to compare the two
fields and show the result in statusitem do that

If (Item1 = Item2) Then
StatusItem = "ok"
Else
StatusItem = "not ok"
End If

otherwise if you have a table and you wanna compare all the item in the
table and save the result in the statusitem field of the same table

Dim dbs As Database, rst As Recordset
Dim strSelect As String


Set dbs = CurrentDb
strSelect = "SELECT * FROM P1ENTRY"
Set rst = dbs.OpenRecordset(strSelect)
do while not rst.eof
rst.edit
If rst![Item1] = rst![Item2] Then
rst![StatusItem] = "ok"
Else
rst![StatusItem] = "not ok"
End If
rst.update
rst.movenext
loop
rst.close
msgbox ("done")

HTH Paolo
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top