Lets see if I understand correctly.
You have a form that you select 1 to 56 people for printing info. The form looks like:Lbl_position
|
Lbl_type
|
Pt_ID
|
Pt_LastName
|
Pt_FirstName
|
Pt_FatherName
|
BirthDate
|
SocSecNo
|
1 |
2 |
|
|
|
|
|
|
2 |
3 |
|
|
|
|
|
|
.... |
|
|
|
|
|
|
|
56 |
1 |
|
|
|
|
|
|
Originally Posted by
jabarlee
I have to create all 56 text field sets (7 for each label) manually, that's A LOT of time... unless anybody knows a way to automate this!
I think you are saying that you have to manually type in the data for Pt_ID, Pt_LastName, Pt_FirstName, Pt_FatherName, BirthDate & SocSecNo for each of the 56 rows..
Each Pt has a unique PT_ID.. yes? You could nave a combo box (cboPTInfo) to select the Pt_ID.
The combo box row source could be something like
Code:
SELECT Pt_ID, Pt_ID & " - " & Pt_LastName & ", " & Pt_FirstName as IDName, Pt_LastName, Pt_FirstName, Pt_FatherName, BirthDate, SocSecNo
FROM tblPatientInfo
ORDER BY Pt_LastName, Pt_FirstName
In the combo box, the settings would be
Bound Column = 1
Column Count = 7
Column widths = 0, 2, 0, 0, 0, 0, 0
There would be code in the combo box after update event to put the values into the proper controls.
So you select the patient by Pt_ID and Name, and the data gets entered into the proper controls.
-----------------------------------------------------------------------------------------
BTW, there is an error in your code. (You have two Case 2 cases)
Code:
Select Case rs1!Lbl_type
Case 1
Me.Controls("txt_LastName_" & i).Visible = True
Me.Controls("txt_FirstName_" & i).Visible = True
Me.Controls("Image_" & i).Visible = True
Me.Controls("txt_BirthDate_" & i).Visible = False
Me.Controls("txt_SocSecNo_" & i).Visible = False
Me.Controls("txt_FatherName_" & i).Visible = False
Me.Controls("txt_FullName_" & i).Visible = False
Me.Controls("txt_Date_" & i).Visible = False
Case 2
Me.Controls("txt_LastName_" & i).Visible = False
Me.Controls("txt_FirstName_" & i).Visible = False
Me.Controls("Image_" & i).Visible = False
Me.Controls("txt_BirthDate_" & i).Visible = True
Me.Controls("txt_SocSecNo_" & i).Visible = True
Me.Controls("txt_FatherName_" & i).Visible = True
Me.Controls("txt_FullName_" & i).Visible = True
Me.Controls("txt_Date_" & i).Visible = True
Case 2 '<------ Shouldn't this be 3 ???
Me.Controls("txt_LastName_" & i).Visible = True
Me.Controls("txt_FirstName_" & i).Visible = True
Me.Controls("Image_" & i).Visible = True
Me.Controls("txt_BirthDate_" & i).Visible = False
Me.Controls("txt_SocSecNo_" & i).Visible = False
Me.Controls("txt_FatherName_" & i).Visible = False
Me.Controls("txt_FullName_" & i).Visible = False
Me.Controls("txt_Date_" & i).Visible = True
End Select
Also you need to close the recordset before setting it to nothing:
Code:
rs1.MoveNext
Next
rs1.Close '<<-- Add this line
Set rs1 = Nothing
End Sub
Since the formatting for Case 1 and 3 are the same except for Me.Controls("txt_Date_" & i).Visible, you could use
Code:
Select Case rs1!Lbl_type
Case 1, 3
Me.Controls("txt_LastName_" & i).Visible = True
Me.Controls("txt_FirstName_" & i).Visible = True
Me.Controls("Image_" & i).Visible = True
Me.Controls("txt_BirthDate_" & i).Visible = False
Me.Controls("txt_SocSecNo_" & i).Visible = False
Me.Controls("txt_FatherName_" & i).Visible = False
Me.Controls("txt_FullName_" & i).Visible = False
Me.Controls("txt_Date_" & i).Visible = (rs1!Lbl_type = 3)
Case 2
Me.Controls("txt_LastName_" & i).Visible = False
Me.Controls("txt_FirstName_" & i).Visible = False
Me.Controls("Image_" & i).Visible = False
Me.Controls("txt_BirthDate_" & i).Visible = True
Me.Controls("txt_SocSecNo_" & i).Visible = True
Me.Controls("txt_FatherName_" & i).Visible = True
Me.Controls("txt_FullName_" & i).Visible = True
Me.Controls("txt_Date_" & i).Visible = True
End Select