B
Bill H.
I have a form on which I populate some unbound fields from a vba sql lookup
based on the contents of a combo box, which changes with each record
right now, I open the table via db.openrecordset and execute a sql string
(build in the module) with a
where clause, and then close out the db.
seems like a lot of opening/closing.
Is there a better and/or faster way to do this?
This is what it looks like now.
Dim db As Database, rs As DAO.Recordset, strSQL, strSQL1 As String
Set db = CurrentDb()
strSQL = "SELECT Qry_Union_FamilyMemberAll.RFS_ID_NO, [firstname] & ' ' &
[lastnameshort] " & _
"AS sName, Tbl_Family_Relation.FamilyRelation AS sRelation " & _
"FROM Qry_Union_FamilyMemberAll LEFT JOIN Tbl_Family_Relation " & _
"ON Qry_Union_FamilyMemberAll.Relationship = Tbl_Family_Relation.PriKey " &
_
"WHERE (((Qry_Union_FamilyMemberAll.RFS_ID_NO)='" & Me.RFS_ID_NO & "'))"
Set rs = db.OpenRecordset(strSQL, dbOpenSnapshot, dbOpenForwardOnly)
If Not rs.BOF And Not rs.EOF Then
Me.fName = rs!sName
Me.fRelation = rs!sRelation
endif
based on the contents of a combo box, which changes with each record
right now, I open the table via db.openrecordset and execute a sql string
(build in the module) with a
where clause, and then close out the db.
seems like a lot of opening/closing.
Is there a better and/or faster way to do this?
This is what it looks like now.
Dim db As Database, rs As DAO.Recordset, strSQL, strSQL1 As String
Set db = CurrentDb()
strSQL = "SELECT Qry_Union_FamilyMemberAll.RFS_ID_NO, [firstname] & ' ' &
[lastnameshort] " & _
"AS sName, Tbl_Family_Relation.FamilyRelation AS sRelation " & _
"FROM Qry_Union_FamilyMemberAll LEFT JOIN Tbl_Family_Relation " & _
"ON Qry_Union_FamilyMemberAll.Relationship = Tbl_Family_Relation.PriKey " &
_
"WHERE (((Qry_Union_FamilyMemberAll.RFS_ID_NO)='" & Me.RFS_ID_NO & "'))"
Set rs = db.OpenRecordset(strSQL, dbOpenSnapshot, dbOpenForwardOnly)
If Not rs.BOF And Not rs.EOF Then
Me.fName = rs!sName
Me.fRelation = rs!sRelation
endif