Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problems with VBA when opening Report

Status
Not open for further replies.
Nov 6, 2002
89
CH
Dear colleagues

I am trying to open a report from a form with VBA. My current code is the following:

___________________________

Option Compare Database

Private Sub Befehl14_Click()

On Error GoTo Err_Befehl14_Click

Dim stDocName As String

stDocName = "Bericht"
DoCmd.OpenReport "Bericht", acPreview, , "[PeriodeID] = " & Me.PeriodeID

Exit_Befehl14_Click:
Exit Sub

Err_Befehl14_Click:
MsgBox Err.Description
Resume Exit_Befehl14_Click

End Sub

_______________________

Unfortunately, it is not working. the following error message comes up:

Microsoft Jet-Database-Module does not recognize '[PeriodeID] as valid field name.

Do you know what is wrong? [PeriodeID] is correct.

Kind regards,

Stefan
 
Hi, Stefan,

try moving the inverted commas:

DoCmd.OpenReport "Bericht", acPreview, , [PeriodeID] & "= " & Me.PeriodeID

or

DoCmd.OpenReport "Bericht", acPreview, , "[PeriodeID] = Me.PeriodeID"

The help file is not that helpful, but my gut feeling is that the inverted commas are in the wrong place.

All the best,

Carol, Berlin :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top