2 Replies - 1747 Views - Last Post: 16 September 2009 - 05:56 PM Rate Topic: -----

#1 marxman89  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 33
  • Joined: 09-July 09

Insert into last row with data

Post icon  Posted 16 September 2009 - 09:42 AM

how can i insert data in a particular field of a last row which contains data(meaning not a null row)



here's a piece of my code:



Dim ltime, ldate As Date
			ltime = TimeValue(Now)
			ldate = DateValue(Now)
			
		 
			
			
			query = "INSERT INTO UserLog(username, accessLevel, loginTime,  logDate) '''
VALUES('" & username1 & "', '" & accessLevel1 & "', '" & ltime & "', '" & ldate & " ')"
			db.Execute (query)
			

			db.Close




notice that there's no logoutTime in the above code.
what should i do in order to specify the last row so that i can insert then the logoutTime.

by the way, this logoutTime is triggered by the event terminate event, that is, whenever the application stops or closes.



here's the code for logoutTime




Dim ltimeout As Date
ltimeout = TimeValue(Now)
  
Call connectdb
Dim rs1 As String
		
		rs1 = "SELECT * FROM UserLog WHERE UserID = (SELECT max(UserID) FROM UserLog)"
		query = "INSERT INTO UserLog(logoutTime) VALUES('" & ltimeout & "') WHERE UserID= '" & rs1 & "')"
		db.Execute (query)
		db.Close






thanks in advance

Is This A Good Question/Topic? 0
  • +

Replies To: Insert into last row with data

#2 raziel_  Icon User is offline

  • Like a lollipop
  • member icon

Reputation: 464
  • View blog
  • Posts: 4,255
  • Joined: 25-March 09

Re: Insert into last row with data

Posted 16 September 2009 - 09:54 AM

is not working ?

what is the error ?

what is the problem with it. is that select the 0 row ?

you can try to send it to variable. see what is the value if you have 20 rows and it select 21 the just subtract 1.
Was This Post Helpful? 0
  • +
  • -

#3 thava  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 180
  • View blog
  • Posts: 1,606
  • Joined: 17-April 07

Re: Insert into last row with data

Posted 16 September 2009 - 05:56 PM

use the update query instead of insert
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1