everest
Goto Top

VBA Access Variable an Query Kriteria weitergeben

Hallo Access-Experten,

kann jemand mir bitte erklären wie ich eine Variable aus einem Formular (über VBA) an Query Kriterien übergebe.

Wie die Screenshots im Anhang unten zeigen. Ich möchte zuerst eine Kategorie aus der Liste selektieren und über den Knopf "Print" einen Report aufrufen. Ich habe leider bis jetzt keine Lösung gefunden wie ich diese Kategorie als Variable an Query zu übergeben.

SELECT AssetCategories.*, Assets.*, Employees.*
FROM Employees INNER JOIN (AssetCategories INNER JOIN Assets ON AssetCategories.AssetCategoryID=Assets.AssetCategoryID) ON Employees.EmployeeID=Assets.EmployeeID
WHERE (((AssetCategories.AssetCategory)=category));

Private Sub selcategory_click()
If me.selcategory = 1 then
category = "Desktop"
goto cat_select
Endif
If me.selcategory = 2 then
category = "Laptop"
goto cat_select
Endif
If me.selcategory = 3 then
category = "iPad"
goto cat_select
Endif
If me.selcategory = 4 then
category = "iPhone"
goto cat_select
Endif

Cat_select:

End Sub

Private Sub Rpt_click()
call selcategory_click
docmd.openReport "Category", acViewPreview
End Sub

Danke im Voraus!
Everest
access

Content-Key: 344961

Url: https://administrator.de/contentid/344961

Printed on: April 19, 2024 at 17:04 o'clock

Member: SlainteMhath
SlainteMhath Jul 31, 2017 at 15:10:36 (UTC)
Goto Top
Moin,

eine Blick in die Hilfe hilft face-smile https://msdn.microsoft.com/de-de/library/office/ff192676.aspx

Für die WhereCondition musst du dir ein entsprechende Bedingung zusammenbasteln.


LG,
Slainte