DBGuyMaybe if you show us your code, we can tell if there's anything we can suggest.
Private Sub cboShopItemID_AfterUpdate()
Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim shopitem As Variant
Dim order As Variant
Set db = CurrentDb
Set rst = db.OpenRecordset("qryWorkOrdersShop", dbOpenDynanset)
Set shopitem = Me.cboShopItemID
order = Left(shopitem, 5)
rst.FindFirst "WOitems" & shopitem
Me.txtJobName.Value = DLookup("JobName", "tblOrders", "OrderNumber =" & order)
Me.txtDescription.Value = rst(Description)
End Sub
Hi. I agree. Hovering on a line that hasn't executed yet will not give you an accurate value at that point in time or the code.DBGuy
Apparently my rs is empty.
I am trying to create it from a union query (qryWorkOrdersShop)
My union qry does not have a PK if that matters but the first field WOItems is a no duplicates field in its underlying table.
On error, when I hover over the highlighted line: Set rst = db.OpenRecordset("qryWorkOrdersShop", dbOpenDynanset) I get a popup message stating the db.OpenDynaset is empty
I am just trying to populate a txtform field on my form with the description field in the query.
Here is my code:
Code:Private Sub cboShopItemID_AfterUpdate() Dim db As DAO.Database Dim rst As DAO.Recordset Dim shopitem As Variant Dim order As Variant Set db = CurrentDb Set rst = db.OpenRecordset("qryWorkOrdersShop", dbOpenDynanset) Set shopitem = Me.cboShopItemID order = Left(shopitem, 5) rst.FindFirst "WOitems" & shopitem Me.txtJobName.Value = DLookup("JobName", "tblOrders", "OrderNumber =" & order) Me.txtDescription.Value = rst(Description) End Sub
OK revised my code but now I can't get to the correct record. What am I doing wrong?DBGuy
Apparently my rs is empty.
I am trying to create it from a union query (qryWorkOrdersShop)
My union qry does not have a PK if that matters but the first field WOItems is a no duplicates field in its underlying table.
On error, when I hover over the highlighted line: Set rst = db.OpenRecordset("qryWorkOrdersShop", dbOpenDynanset) I get a popup message stating the db.OpenDynaset is empty
I am just trying to populate a txtform field on my form with the description field in the query.
Here is my code:
Code:Private Sub cboShopItemID_AfterUpdate() End Sub
Private Sub cboShopItemID_AfterUpdate()
Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim shopitem As Variant
Dim order As Variant
Set db = CurrentDb
Set rst = db.OpenRecordset("qryWorkOrdersShop")
Set shopitem = Me.cboShopItemID
order = Left(shopitem, 5)
rst.FindFirst ("WOitems" = shopitem)
Me.txtJobName.Value = DLookup("JobName", "tblOrders", "OrderNumber =" & order)
Me.txtDescription.Value = rst!Description.Value
End Sub
You have to execute the line to see any values?
I mentioned this in the other thread
Might also want to lookup how to use FindFirst?
![]()
Recordset.FindFirst method (DAO)
Office developer client VBA reference documentationdocs.microsoft.com
I couldn't get past the set recordset line due to trying to open it as a db.opendynaset type.You have to execute the line to see any values?
I mentioned this in the other thread
Might also want to lookup how to use FindFirst?
![]()
Recordset.FindFirst method (DAO)
Office developer client VBA reference documentationdocs.microsoft.com
So for .FindFirst, I have to .cone to a new recordset with only one record, is that how's it's done?You have to execute the line to see any values?
I mentioned this in the other thread
Might also want to lookup how to use FindFirst?
![]()
Recordset.FindFirst method (DAO)
Office developer client VBA reference documentationdocs.microsoft.com
No. Little point in having a Find First in that case, would it?, if there is only one record?So for .FindFirst, I have to .cone to a new recordset with only one record, is that how's it's done?
So findfirst then clone then bookmark the record?No. Little point in having a Find First in that case, would it?, if there is only one record?
Private Sub cboShopItemID_AfterUpdate()
Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim shopitem As Variant
Dim order As Variant
Set db = CurrentDb
Set rst = db.OpenRecordset("qryWorkOrdersShop")
Set shopitem = Me.cboShopItemID
order = Left(shopitem, 5)
Me.txtJobName.Value = DLookup("JobName", "tblOrders", "OrderNumber =" & order)
Me.txtDescription = rs!Descrption
End Sub
I don't know how to do that, can you show me?Whilst it is perfectly possible, why are you bothering with a recordset anyway?
Just filter your UNION query to get the record you need. Much easier
There is no loop there?Ok so I did this and locked up access, I am assuming in a continuous loop:
Code:Private Sub cboShopItemID_AfterUpdate() Dim db As DAO.Database Dim rst As DAO.Recordset Dim shopitem As Variant Dim order As Variant Set db = CurrentDb Set rst = db.OpenRecordset("qryWorkOrdersShop") Set shopitem = Me.cboShopItemID order = Left(shopitem, 5) Me.txtJobName.Value = DLookup("JobName", "tblOrders", "OrderNumber =" & order) Me.txtDescription = rs!Descrption End Sub
I don't know how to do that, can you show me?
I read the entire page, I just don't get what I am doing wrong.For all the comments on concatenation in that other thread, you just go ahead and do the same thing in this thread?
You did not read much of the link I gave you did you, an example is actually on there?
SELECT * FROM qryYourUnionQueryName WHERE OrderNumber = order
That doesn't work, but WOItems is a string or variant, it is a field in my query concatenated from a long field and (2) short text fields.Re #7, that should be
if WOintems is numericCode:rst.FindFirst ("WOitems = " & shopitem)