Conditions for opening a report

  • Thread starter Thread starter estdoj
  • Start date Start date
E

estdoj

Guest
Hi
Im trying to open a report from a form (excause my terrible language, im trying my best). In the VBA behind I have this code and it works BUT I want to use two conditions and I dont know the syntax or if its possible at all...PID is the first condition from my form but I also want to select a other field to match for opening the report, someone who knows how I do this in VBA-code???

Private Sub Öppna_rapport_Click()
DoCmd.OpenReport "rapPersonMedAllt", acViewNormal, , "PID=" & PID
End Sub

Now are three pages generated at each time because the database always have three rows for each PID but they have different values in this field wich I want to use. PID is my key but in this question on wich I built my form I use a combinationkey for unic rows.

I have also problems with showing the hole text in my report (Access wants only give me 255 signs but I have more to show). My database is a MySql and I have to use the VBA-code below for showing the hole text in my form and it works perfect. BUT how do I write it for a form?

Private Sub Form_Current()

Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
rs.Open "select erfarenhet from tblPerson where PID=" & Me.Recordset("PID"), CurrentProject.Connection
'MsgBox rs.Fields(0).Type & "," & Len(rs(0))
Text58 = rs(0)
Set rs = Nothing

End Sub

Happy if someone can help me...
 
Try something along this line:

This is for OtherValue numeric.
Code:
DoCmd.OpenReport "rapPersonMedAllt", acViewNormal, , "PID=" & PID & " AND anotherField = " & OtherValue

This is for OtherValue alpha.
Code:
DoCmd.OpenReport "rapPersonMedAllt", acViewNormal, , "PID=" & PID & " AND anotherField = '" & OtherValue & "'"
 
Thanks a lot, it works perfect now!
 

Users who are viewing this thread

Back
Top Bottom