HELPME! I have issues!

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi I hope someone here can help me. I am working on a db and I can't remember
how to make an If Me! Then... statement in VB. I want to be able to select an
item from an option button, and click on another button and it will bring up
the one item I selected in Print Preview. I know that it has something to do
with if then statments but I can't remember how it all goes. Can someone
please help me>???
 
Okay I think I may be onto something here's what I have so far.


Private Sub optprint_Click()
If Me.[All] = True Then
DoCmd.OpenReport "Mailing Labels All", acPreview
ElseIf Me.[Date] = True Then
DoCmd.OpenReport "Mailing Lables by date", acPreview
ElseIf Me.[ID] = True Then
DoCmd.OpenReport "Mailing labels by id", acPreview
End If
End Sub


Am I supposed to let me= something?

Am I even on the right track?
I would appreciate any help!
 
Hi,

Are your options inside on option group frame? If they are, you can refer
to the value of the group frame, using a SELECT CASE statement to find out
what the user clicked.

e.g.
'****************************START
Private Sub cmdOpenReport_Click
Dim strReport as String

Select Case fraYourOptionGroupFrame
Case 1
strReport = "Mailing Labels All"
Case 2
strReport = "Mailing Lables by date"
Case 3
strReport = "Mailing labels by id"
Case Else
MsgBox "Please select a report to preview."
GoTo Exit_cmdReportOpen_Click
End Select

DoCmd.OpenReport strReport, acPreview

Exit_cmdReportOpen_Click:
Exit Sub

End Sub
'********************************END
Where:
* fraYourOptionGroupFrame is the name of the option group frame on your form
* Each case statements value (1,2, etc) is the value of a corresponding
option
selected in the group


Jamie
 
Looks fine although normally you would read the frame (option group) ala

Private Sub Command8_Click()
Dim rptName As String
Select Case Me.Frame0
Case 1
rptName = "Report1"
Case 2
rptName = "Report2"
Case 3
rptName = "Report3"
End Select
DoCmd.OpenReport rptName, acPreview
End Sub

See www.papwalker.com/public/optiongrp.zip
for a sample database app on this.

peter walker
 
Thank you Thank you Thank you!!!! I have been giving myself a headache of
this stupid thing and you guys all made it so easy for me!
I have another issue if I may.

I have seen this problem outlined elseware but I am not sure if it is
exactly what I need. I have a table with for example contact info and I have
another table that has information on events. I want to be able to have a
form that when I select 10 people that went to an event that it goes into my
orignal table of people/evetn. right now I am putting each person in there
seperately. I also have anotherr table linked to the event table by person
that indicates what they paid per event which is not always the same per
person. Can you guys help me iwht this also? Does this make sense?

Jamie Richards said:
Hi,

Are your options inside on option group frame? If they are, you can refer
to the value of the group frame, using a SELECT CASE statement to find out
what the user clicked.

e.g.
'****************************START
Private Sub cmdOpenReport_Click
Dim strReport as String

Select Case fraYourOptionGroupFrame
Case 1
strReport = "Mailing Labels All"
Case 2
strReport = "Mailing Lables by date"
Case 3
strReport = "Mailing labels by id"
Case Else
MsgBox "Please select a report to preview."
GoTo Exit_cmdReportOpen_Click
End Select

DoCmd.OpenReport strReport, acPreview

Exit_cmdReportOpen_Click:
Exit Sub

End Sub
'********************************END
Where:
* fraYourOptionGroupFrame is the name of the option group frame on your form
* Each case statements value (1,2, etc) is the value of a corresponding
option
selected in the group


Jamie

purpleme3 said:
Okay I think I may be onto something here's what I have so far.


Private Sub optprint_Click()
If Me.[All] = True Then
DoCmd.OpenReport "Mailing Labels All", acPreview
ElseIf Me.[Date] = True Then
DoCmd.OpenReport "Mailing Lables by date", acPreview
ElseIf Me.[ID] = True Then
DoCmd.OpenReport "Mailing labels by id", acPreview
End If
End Sub


Am I supposed to let me= something?

Am I even on the right track?
I would appreciate any help!
 
This would be a good instance to use a sub-form.
The main form would hold the Event...the subform would be for the
attendees...along with whatever other fields (Cost etc.) that you want.

HTH
Mal.

purpleme3 said:
Thank you Thank you Thank you!!!! I have been giving myself a headache of
this stupid thing and you guys all made it so easy for me!
I have another issue if I may.

I have seen this problem outlined elseware but I am not sure if it is
exactly what I need. I have a table with for example contact info and I have
another table that has information on events. I want to be able to have a
form that when I select 10 people that went to an event that it goes into my
orignal table of people/evetn. right now I am putting each person in there
seperately. I also have anotherr table linked to the event table by person
that indicates what they paid per event which is not always the same per
person. Can you guys help me iwht this also? Does this make sense?

Jamie Richards said:
Hi,

Are your options inside on option group frame? If they are, you can refer
to the value of the group frame, using a SELECT CASE statement to find out
what the user clicked.

e.g.
'****************************START
Private Sub cmdOpenReport_Click
Dim strReport as String

Select Case fraYourOptionGroupFrame
Case 1
strReport = "Mailing Labels All"
Case 2
strReport = "Mailing Lables by date"
Case 3
strReport = "Mailing labels by id"
Case Else
MsgBox "Please select a report to preview."
GoTo Exit_cmdReportOpen_Click
End Select

DoCmd.OpenReport strReport, acPreview

Exit_cmdReportOpen_Click:
Exit Sub

End Sub
'********************************END
Where:
* fraYourOptionGroupFrame is the name of the option group frame on your form
* Each case statements value (1,2, etc) is the value of a corresponding
option
selected in the group


Jamie

purpleme3 said:
Okay I think I may be onto something here's what I have so far.


Private Sub optprint_Click()
If Me.[All] = True Then
DoCmd.OpenReport "Mailing Labels All", acPreview
ElseIf Me.[Date] = True Then
DoCmd.OpenReport "Mailing Lables by date", acPreview
ElseIf Me.[ID] = True Then
DoCmd.OpenReport "Mailing labels by id", acPreview
End If
End Sub


Am I supposed to let me= something?

Am I even on the right track?
I would appreciate any help!
 
Back
Top