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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Please help 1

Status
Not open for further replies.

mrathi

Technical User
Oct 27, 2003
115
US
Hi, This is kind of weird. i have created a report. I also have some event procedures for it. Now, if I have 5 records (ex: I have 5 units), each unit comes on to a new page in the report. In the even procedure, based on some condition in the unit, I have some labels and textboxes hidden. However, Once the code in VB is executed for one unit, then it remains the same and the other units does not work properly. For example, if the label is set to false in the first unit, then, the second unit will also have it false, not matter what the condition.

In some cases, it shows only in the last unit and not on the previous units. I hope I haven't confused anybody. tried to explain as much as I could.

Thanks for any help.
 
post you code for the report....Sounds like you are using If statements to hide or show and don't have else statements to set back to default each time...

****************************
People think it must be fun to be a super genius, but they don't realize how hard it is to put up with all the idiots in the world. (Calvin from Calvin And Hobbs)

Robert L. Johnson III
MCSA, CNA, Net+, A+
w: rljohnso@stewart.com
h: wildmage@tampabay.rr.com
 
mstrmage1768 deserves a star for a good guess and proper reply.

Duane
MS Access MVP
 
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Dim rptfrmName As String
Dim rpteqid As Variant

Me!ConfManuf.Visible = False

rpteqid = Me!EquipmentID
rptfrmName = "frmboiler"
Call ConfidentialReportDisplay(rptfrmName, rpteqid)
End Sub

Sub ConfidentialReportDisplay(fname As String, eqid As Variant)
Dim rst As Recordset
Dim CurrentProject As Long
Dim FoundItem As Boolean
Dim EqIDCheck As Long
Dim fldName As String
Dim SQL_Delete As String
Dim frm As Form
Dim FormIsOpen As Boolean

CurrentProject = Forms!frm_ProjectManagement_Info.ProjectIdentifier
Set rst = CurrentDb.OpenRecordset("tblConfInfoData", dbOpenDynaset)
FoundItem = False

rst.FindFirst ("ProjectIdentifier = " & CurrentProject & " AND FormCtrl = '" & fname & "'")

While Not rst.NoMatch
fldName = rst!FormField

Select Case fname

Case "frmboiler"
If eqid = rst!EquipmentID Then
Reports!MrptEUBoilers!ConfManuf.Visible = True
Reports!MrptEUBoilers!Manufacturer.Visible = False

Else
Reports!MrptEUBoilers!ConfManuf.Visible = False
Reports!MrptEUBoilers!Manufacturer.Visible = True

End If

 
Looks like you need to set the properties back using Case Else in you Select Case structure.
I would also filter the recordset by using
strSQL = "Select * from tblConfInfoData where ProjectIdentifier =" & CurrentPRoject & " And FormCtgrl='" fname & "'"
Set rst = Currentdb.OpenRecordset(strSQL, dbopendynaset)

Duane
MS Access MVP
 
I did not understand your first statement. Can you please give more info? Thanks
 
Ok, something chnaged, I don't know how. I had five units in this particular report. With my previous query without the filter, I could see the confidential, for one particular unit and not others. After I changed to what you said, filtering the recordset, some other unit is showing the confidential, and not the previous and the other ones. So basically, it is still showing only one unit and not others where applicable

Thanks
 
As mstrmage1768 suggested, if you have code that sets some properties, you need additional code that sets it back for all other cases. Your code only sets the properties back if FName = "frmBoiler". If FName is any other value, the format properties are ignored and remain the same as the most previous record where FName="frmBoiler".

Duane
MS Access MVP
 
Ok, let me explain it again. I have a report and this is the code in the VB part of only this report:

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Dim rptfrmName As String
Dim rpteqid As Variant

Me!ConfManuf.Visible = False

rpteqid = Me!EquipmentID
rptfrmName = "frmboiler"
Call ConfidentialReportDisplay(rptfrmName, rpteqid)
End Sub

Now, I have a module and this is a the code that is common to the whole module:
Sub ConfidentialReportDisplay(fname As String, eqid As Variant)
Dim rst As Recordset
Dim CurrentProject As Long
Dim FoundItem As Boolean
Dim EqIDCheck As Long
Dim fldName As String
Dim SQL_Delete As String
Dim frm As Form
Dim FormIsOpen As Boolean

CurrentProject = Forms!frm_ProjectManagement_Info.ProjectIdentifier
Set rst = CurrentDb.OpenRecordset("tblConfInfoData", dbOpenDynaset)
FoundItem = False

rst.FindFirst ("ProjectIdentifier = " & CurrentProject & " AND FormCtrl = '" & fname & "'")

While Not rst.NoMatch
fldName = rst!FormField

Now related to my report above this is the code in the module:
Select Case fname

Case "frmboiler"
If eqid = rst!EquipmentID Then
Reports!MrptEUBoilers!ConfManuf.Visible = True
Reports!MrptEUBoilers!Manufacturer.Visible = False

Else
Reports!MrptEUBoilers!ConfManuf.Visible = False
Reports!MrptEUBoilers!Manufacturer.Visible = True

End If

The other cases are for other reports.
Can you please tell me now, where I am wrong? Thanks
 
I would place a breakpoint early in the code and step through the lines of code to identify a possible logic error.

Duane
MS Access MVP
 
Thanks for all your help. I have a question. With my previous Set rst statement, I could see the last unit properly and the first units did not show right. When I changed the Set rst statement to what Duane suggested, I could see the first one correct, but not the rest ones. Please help.

Thanks again
 
You must learn how to debug by setting breakpoints and using Debug.Print and MsgBox within your code. Your questions can't easily be answered by looking at snippets of your code.

Duane
MS Access MVP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top