"Query" problem

freetobreed

New member
Local time
Today, 10:30
Joined
Jan 6, 2005
Messages
6
Every time i try to get the value on the field numero chamada it returns me the value 4 even if before the value it's different (let's say 15). Instead of giving me back the value 16 it gives me every time 4. Can anyone explain me why?

Thanks

Here's the code below :)

Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim num As Integer

' open a connection to the current database
Set db = CurrentDb
Set rs = db.OpenRecordset("Log")
rs.MoveLast
num = rs.Fields("numero chamada")
numerochamada.SetFocus
numerochamada.Text = num + 1
rs.AddNew
rs.Fields("numero chamada").Value = numerochamada.Text
rs.Update
rs.Close
Exit Sub
 
In VBA, contrary to VB, you should use .VALUE instead of .TEXT. This way, you don't have to set focus.
 
FLabrecque said:
In VBA, contrary to VB, you should use .VALUE instead of .TEXT. This way, you don't have to set focus.

If i do that the app does not even run me at all :)
 
Last edited:
Order By?

When you open your r-set on "Log", it is probably not ordered as you are expecting. Perhaps use something like...

Set rs = CurrentDb.OpenRecordset( _
"SELECT * FROM Log " & _
"ORDER BY nummychummy;")

...in this situation your last record will contain your highest nummychummy.
 

Users who are viewing this thread

Back
Top Bottom