C
C. Clark
I've read so much in lots of different forums about the wonderful getstring()
method for recordsets, and really need it for some code I'm trying to use.
Here's what I've got so far:
Dim dbs As Database
Dim VenueNew, VenueOld, VenNewName, VenOldName, sql As String
Dim rs As Recordset
VenueOld = eqpVenue.OldValue
VenueNew = Me.eqpVenue
If VenueOld <> VenueNew Then
Set dbs = CurrentDb
sql = " SELECT vnuVenue FROM tblVenue WHERE vnuID = " &
VenueOld & ";"
Set rs = dbs.OpenRecordset(sql)
VenOldName = rs.GetString()
sql = " SELECT vnuVenue FROM tblVenue WHERE vnuID = " &
VenueNew & ";"
Set rs = dbs.OpenRecordset(sql)
VenNewName = rs.GetString()
dbs.Execute " INSERT INTO tblRepairs
(rprComments,rprEquipID) VALUES ('Moved from " & VenOldName & " to " &
VenNewName & "', '" & Me.eqpID & "');"
dbs.Close
Me.Refresh
End IF
I've truncated some stuff, but what I'm attempting to make the code do is
get the old and new values of a form field directly related to one table, and
insert a record into another table with both the old and new values. The hard
part lies in the fact that the field that gets changed for this is lniked to
another table via the lookup wizard using the autonumber primary key. So I
need to use the SQL select to lookup the text field related to the primary
key field, and want the getstring to grab the text out of the recordset
returned and inserted into the sql insert query.
According to what I've read, any ADO 2.x Library should include it. I'm
using Access 2003 with VBA 6.3, and I've got ADO 2.8 refereneced, as well as
ADO Recordset 2.8, and DAO 3.6. But despite all this, and trying different
versions of ADO, I can't get the recordset.getstring() method to show up or
be recognized.
Is there something I'm doing wrong? Is there a better way to do what I'm
trying to do?
Thanks in advance - Chris.
method for recordsets, and really need it for some code I'm trying to use.
Here's what I've got so far:
Dim dbs As Database
Dim VenueNew, VenueOld, VenNewName, VenOldName, sql As String
Dim rs As Recordset
VenueOld = eqpVenue.OldValue
VenueNew = Me.eqpVenue
If VenueOld <> VenueNew Then
Set dbs = CurrentDb
sql = " SELECT vnuVenue FROM tblVenue WHERE vnuID = " &
VenueOld & ";"
Set rs = dbs.OpenRecordset(sql)
VenOldName = rs.GetString()
sql = " SELECT vnuVenue FROM tblVenue WHERE vnuID = " &
VenueNew & ";"
Set rs = dbs.OpenRecordset(sql)
VenNewName = rs.GetString()
dbs.Execute " INSERT INTO tblRepairs
(rprComments,rprEquipID) VALUES ('Moved from " & VenOldName & " to " &
VenNewName & "', '" & Me.eqpID & "');"
dbs.Close
Me.Refresh
End IF
I've truncated some stuff, but what I'm attempting to make the code do is
get the old and new values of a form field directly related to one table, and
insert a record into another table with both the old and new values. The hard
part lies in the fact that the field that gets changed for this is lniked to
another table via the lookup wizard using the autonumber primary key. So I
need to use the SQL select to lookup the text field related to the primary
key field, and want the getstring to grab the text out of the recordset
returned and inserted into the sql insert query.
According to what I've read, any ADO 2.x Library should include it. I'm
using Access 2003 with VBA 6.3, and I've got ADO 2.8 refereneced, as well as
ADO Recordset 2.8, and DAO 3.6. But despite all this, and trying different
versions of ADO, I can't get the recordset.getstring() method to show up or
be recognized.
Is there something I'm doing wrong? Is there a better way to do what I'm
trying to do?
Thanks in advance - Chris.