B
BlueWolverine
Hello,
I have a query that doesn't work, though it should. I am really irritated
that I can't figure it out. There is a post from today under queries if you
are interested in addressing it.
Anyway, the reason I bring that up is I think I can work around that by
writing the select query in sql as a string, and then open that recordset in
vba. This way I can write the SQL and use a variable from VBA to narrow down
by my criteria, the problem is I have no idea how to do that.
I want to
1. generate a query from VBA
strSQL = cstr("SELECT t_FuelCardInventory.FuelCardProvider,
t_FuelCardInventory.VIN
FROM t_FuelCardInventory
WHERE (((t_FuelCardInventory.FuelCardProvider)='" & FCProvi & "') AND
((t_FuelCardInventory.VIN)='" & FCVIN & "'));")
2. perform the following action
Set RS = mydb.openrecordset(strSQL)
Alternatively,
Can you pass a VBA variable to an established and written query, so that in
design mode, the criteria looks like module!Program.FCVIN or soemthing like
that?
Here is the SQL that DOES NOT RETURN RECORDS I KNOW FOR FACT EXIST.. I can
scroll through the damn table and see them.
SELECT t_FuelCardInventory.FuelCardProvider, t_FuelCardInventory.VIN
FROM t_FuelCardInventory
WHERE (((t_FuelCardInventory.FuelCardProvider)='" &
[Forms]![f_SearchPanel]![GlobalFCProvi] & "') AND
((t_FuelCardInventory.VIN)='" & Forms![f_SearchPanel]![GlobalVIN] & "'));
I am using MS Access 2003 on XP Pro. Thank you
I have a query that doesn't work, though it should. I am really irritated
that I can't figure it out. There is a post from today under queries if you
are interested in addressing it.
Anyway, the reason I bring that up is I think I can work around that by
writing the select query in sql as a string, and then open that recordset in
vba. This way I can write the SQL and use a variable from VBA to narrow down
by my criteria, the problem is I have no idea how to do that.
I want to
1. generate a query from VBA
strSQL = cstr("SELECT t_FuelCardInventory.FuelCardProvider,
t_FuelCardInventory.VIN
FROM t_FuelCardInventory
WHERE (((t_FuelCardInventory.FuelCardProvider)='" & FCProvi & "') AND
((t_FuelCardInventory.VIN)='" & FCVIN & "'));")
2. perform the following action
Set RS = mydb.openrecordset(strSQL)
Alternatively,
Can you pass a VBA variable to an established and written query, so that in
design mode, the criteria looks like module!Program.FCVIN or soemthing like
that?
Here is the SQL that DOES NOT RETURN RECORDS I KNOW FOR FACT EXIST.. I can
scroll through the damn table and see them.
SELECT t_FuelCardInventory.FuelCardProvider, t_FuelCardInventory.VIN
FROM t_FuelCardInventory
WHERE (((t_FuelCardInventory.FuelCardProvider)='" &
[Forms]![f_SearchPanel]![GlobalFCProvi] & "') AND
((t_FuelCardInventory.VIN)='" & Forms![f_SearchPanel]![GlobalVIN] & "'));
I am using MS Access 2003 on XP Pro. Thank you