Access-VB: Report_Open

VBAnfänger

Grünschnabel
Hallo Ihr,

ich möchte gerne beim Öffnen eines Berichtes, das sich das entsprechende Ereignis auslöst. --> funzt auch... Soweit so gut.

Nun möchte ich, daß der Benutzer ein Datum eingibt im Format [mm jjjj] und das dann alle Daten in dem Bericht ausgegeben werden, die diese Abfrage erfüllen.

Das habe ich auch soweit, nur das Problem ist, daß das Datum in der Tabelle das Format Datum/Uhrzeit hat. Ich brauche aber für die Abfrage das Format [mm jjjj]. Und ich gebe einen String ein. Weiß nicht, ob ich das in meinem Programm konvertieren muss oder ob es besser wäre, wenn ich das Format in der DB ändere.

Und dann möchte ich noch, daß die Variable strWert in meinem Bericht als Datum, sprich Format$([strWert];"mmmm jjjj";0;0) wieder ausgegeben wird.

Oh mann ich hoffe, daß irgendjemand durch meinen Wust durchkommt und mir helfen kann.

Hier erstmal mein Progrämmelchen:

Private Sub Report_Open(Cancel As Integer)
Dim strWert As String

strWert = InputBox("Welcher Monat?", "Frage", "04 2003")

Dim strTest As String

Report.RecordSource = "SELECT [accounting_customer].[name] AS accounting_customer_name, [accounting_application].[fullname], [accounting_author].[name] AS accounting_author_name, [accounting_map].[name] AS accounting_map_name, [accounting_sum_map].[month], [accounting_sum_map].[count], [accounting_application].[id], [accounting_author].[authorid], [accounting_customer].[id] AS customer_id FROM (accounting_author INNER JOIN accounting_map ON [accounting_author].[authorid]=[accounting_map].[authorid]) INNER JOIN ((accounting_customer INNER JOIN accounting_application ON [accounting_customer].[id]=[accounting_application].[customerid]) INNER JOIN accounting_sum_map ON [accounting_application].[id]=[accounting_sum_map].[applicationid]) ON [accounting_map].[id]=[accounting_sum_map].[mapid]

WHERE FORMAT([accounting_sum_map].[month]," & """" & "mmjjjj" & """" & ") = '" & strWert & "'"

End Sub

Danke, Sandra
 
Servus!

versuchs mal mit:

...
WHERE FORMAT(CDATE([accounting_sum_map].[month]),"mm yyyy") LIKE '" & strwert & "'"

...

Gruss Tom
 
Hallo Tom,

erstmal danke für Deine Antwort.

Habe es schon hinbekommen.

Und so gehts:
...
FORMAT([accounting_sum_map].[month]," & """" & "mmyyyy" & """" & ") = '" & strWert & "'
...

cu, Sandra
 

Neue Beiträge

Zurück