|
-
Dec 9th, 2001, 05:24 PM
#1
Thread Starter
Hyperactive Member
how do u show updates to a grid?

Private Sub dbgResp_AfterUpdate()
Dim selectS As String
rstResults.MoveFirst
While rstResults.EOF = False
With rstResults
.Edit
!TimeDiff = "blah"
.Update
End With
rstResults.MoveNext
Wend
'something missing here
End Sub
what i want this to do is, each time the user changes a cell on my dbgResp datagrid, i want it to change the timediff column to say blah, all good.
but i want it to also update the grid, to show the changes, i tried doing a refresh, how can i make it show the new "blah" value?
-
Dec 11th, 2001, 02:48 AM
#2
Fanatic Member
okay try doing something like this
VB Code:
Private Sub dbgResp_AfterUpdate()
Dim selectS As String
rstResults.MoveFirst
Do Until rstResults.EOF
With rstResults
.Edit
!TimeDiff = "blah"
.Update
End With
rstResults.MoveNext
Loop
dbgResp.ReBind
End Sub
you should use a do loop instead a while wend as a do loop is more robust and efficient method.
-
Dec 11th, 2001, 02:54 AM
#3
PowerPoster
Well technically this is the fastest method of going through a recordset!
Using rudvs2 code!
VB Code:
Private Sub dbgResp_AfterUpdate()
Dim selectS As String
rstResults.MoveLast
intRecCount=rstResults.RecordCount
rstResults.MoveFirst
For intCounter=1 To intRecCount
With rstResults
.Edit
!TimeDiff = "blah"
.Update
End With
rstResults.MoveNext
Next intCounter
dbgResp.ReBind
End Sub
Bloddy nzenders taking over the place!
-
Dec 11th, 2001, 05:59 PM
#4
Fanatic Member
Bloddy Aussies always having to have the last say 
lol
-
Dec 11th, 2001, 07:08 PM
#5
Thread Starter
Hyperactive Member
im baaaack >=)
whew, stupid lab technician made me make some stupid bags with the laminator, how rude, pfft
neway, i turned that code into a for next an all very cool, but it still doesnt really help me, i tried had a rebind on it already, but it didnt seem to work
??
-
Dec 11th, 2001, 07:11 PM
#6
Thread Starter
Hyperactive Member
in fact it as a rebind and a requery on it at the mo, have a look :
For i = 1 To RecCount
CurrDate = rstThisTest.Fields("Date")
If IsNull(CurrDate) Then
Else
CurrTime = rstThisTest.Fields("Time")
If IsNull(CurrTime) Then
Else
CurrDateTime = CurrDate + CurrTime
CurrDateTime = CDate(CurrDateTime)
TimeD = DateDiff("h", OrigDateTime, CurrDateTime)
With rstThisTest
.Edit
!TimeDiff = TimeD
.Update
End With
End If
End If
rstThisTest.MoveNext
Next i
rstThisTest.Requery
dbgResp.ReBind
End Sub
-
Dec 11th, 2001, 07:20 PM
#7
Fanatic Member
just to be a pain in the rectum I reformatted your code again to make it easier to follow
didnt fix your prob though 
VB Code:
For i = 1 To RecCount
CurrDate = rstThisTest.Fields("Date")
Select Case IsNull(CurrDate)
Case Is = True
Exit Sub
Case Else
CurrTime = rstThisTest.Fields("Time")
Select Case IsNull(CurrTime)
Case Is = True
Exit Sub
Case Else
CurrDateTime = CurrDate + CurrTime
CurrDateTime = CDate(CurrDateTime)
TimeD = DateDiff("h", OrigDateTime, CurrDateTime)
With rstThisTest
.Edit
!TimeDiff = TimeD
.Update
End With
End Select
End Select
rstThisTest.MoveNext
Next i
rstThisTest.Requery
dbgResp.ReBind
-
Dec 11th, 2001, 07:23 PM
#8
Banned
-
Dec 11th, 2001, 07:42 PM
#9
Thread Starter
Hyperactive Member
-
Dec 11th, 2001, 07:43 PM
#10
Banned
-
Dec 11th, 2001, 09:02 PM
#11
Thread Starter
Hyperactive Member
nonono that's what u told me to do yesterday, it doesnt like that tho, comes up method or datamember not found, it doesnt reconise the .refresh method for my recordset
-
Dec 11th, 2001, 09:04 PM
#12
Thread Starter
Hyperactive Member
mind u, when i go type
dim rstblah as...
it gives me recordset 3 times in the list of choices, does that mean they're all different things with the same name? how on earth am i ment to know which one to pick?
-
Dec 11th, 2001, 09:12 PM
#13
PowerPoster
Sorry forgot!
Are u using ado or dao or what??
If adodb you should pick like:
Private rs As ADODB.Recordset
then set it!
later b
-
Dec 11th, 2001, 09:22 PM
#14
Thread Starter
Hyperactive Member
i think it must be dao, because now i get an errors on this line further back
the old datatype mismatch 
Set rstThisTest = dbsRespiration_Testing.OpenRecordset(selectS)
how can i turn it all into ado? is it a mission?
-
Dec 11th, 2001, 09:30 PM
#15
PowerPoster
Depends how big your project is!
Your not using any datacontrols are you?
If not just check the Project/Referneces menu and see which data object is ticked!
I.e Microsoft Data Object Library 4.0 = DAO
Later
b
-
Dec 11th, 2001, 09:32 PM
#16
Fanatic Member
to turn it into ado from dao shouldnt be to muc hard work
however if you are using a datacontrol (this uses dao) it might be a bit harder
You could always try using the ado datacontrol (ughh) but i would recomend that you get stuck into writing the code yourself and using the ado dataobject
to create aan ado connection you need to do the following
First go to the references option in the priject menu of vb and add a reference to the Microsoft Activex Data Object Library
VB Code:
Dim Rs As ADODB.RecordSet
Set Rs = New ADODB.RecordSet
Rs.ActiveConnection = "Provider=Microsoft.JET.OLEDB.3.51;Data Source=" & your database path goes here
Rs.Open "SELECT * From your table", , adOpenKeyset, adLockOptimistic
'to retreive or set record values it is like this
myVar = Rs.Fields("Myfield").Value
Rs.Fields("MyField").Value = myVar
'you do not need to invoke an edit to replace values just place an update after changing them
Rs.Update
'to add records
With Rs
.Add
.Fields("MyField").Value = myVar
End With
'there is of coarse a heap more than just that but that gives you the basics
-
Dec 11th, 2001, 09:34 PM
#17
Thread Starter
Hyperactive Member
-
Dec 11th, 2001, 10:01 PM
#18
-
Dec 11th, 2001, 10:29 PM
#19
Thread Starter
Hyperactive Member
shhh! dont breathe i think it's almost working 
i havent changed it all over tho, i realised i hadnt tired refreshing the ado it was connected to, ah ha 
so i have the timediff showing, only it's only behind, it only shows 1-3 or 4 ...
ah, u guys are so lovely
-
Dec 11th, 2001, 10:31 PM
#20
Thread Starter
Hyperactive Member
man that was full of typos, only it's ONE behind, and 1-3 OF 4
hopeless
-
Dec 12th, 2001, 02:45 PM
#21
Thread Starter
Hyperactive Member
still missing one
im nearly there 
does anybody know why i might be not showing the last one? it only displays the time difference, after u update the next row, ie. when u have done rows 1,2 and 3, it will show the result of 1 and 2, once u do # 4, 1,2 and 3 are displayed
Private Sub dbgResp_AfterUpdate()
Dim OrigDateTime As Variant
Dim CurrDateTime As Variant
Dim RefreshBookmark As Variant
Dim TimeD As Single
Dim selectS As String
Dim CurrTime As Variant
Dim CurrDate As Variant
Dim Bmark As Variant
Dim RecCount As Integer
Dim i As Integer
'get initial date/time
OrigDateTime = testdate
OrigDateTime = OrigDateTime + " " + testtime
OrigDateTime = CDate(OrigDateTime)
rstThisTest.Requery
For i = 1 To NumbTests
CurrDate = rstThisTest.Fields("Date")
If IsNull(CurrDate) Then
Else
CurrTime = rstThisTest.Fields("Time")
If IsNull(CurrTime) Then
Else
CurrDateTime = CurrDate + CurrTime
CurrDateTime = CDate(CurrDateTime)
TimeD = DateDiff("h", OrigDateTime, CurrDateTime)
With rstThisTest
.Edit
!TimeDiff = TimeD
.Update
End With
End If
End If
rstThisTest.MoveNext
Next i
'rstThisTest.Requery
adoResp.Refresh
dbgResp.Refresh
-
Dec 12th, 2001, 03:46 PM
#22
-
Dec 12th, 2001, 04:51 PM
#23
Thread Starter
Hyperactive Member
your probably right, damn me and my mishmash 
hehe, ooh &, i didnt know about that, that'll save me heaps of mucking around, heh, i can delete half me variables now 
i can send u that email either, it's the db, it's to big to fit on a disk or a hotmail thingy, i duno why, theres only 2 stupid tables :-/ argh
-
Dec 12th, 2001, 05:07 PM
#24
Fanatic Member
rename your db for a mo run the visual data manager in the add ins menu of your vb and from file select compact database browse to your renamed db and select it for the new db name it will want put in the old name that your db was this will result in you having a compacted db with the original file name
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|