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

Errror 2165 - You can't hide a control that has the focus in report Detail_Format

Status
Not open for further replies.

PeDa

Technical User
Oct 10, 2002
227
NL
I am getting this error message when I try to open a form. It refers to a field I sometimes need to hide by setting its Visible property to false, if it contains invalid data. However I have not actually set the focus to this field (and wasn't aware that report fields could have the focus, and can't see how to move the focus elsewhere)
 
This forum is for reports but your question starts with "when I try to open a form". Then you finish with mention of report fields. You never provide any code or context.

Duane
Hook'D on Access
MS Access MVP
 
Oeps; reference to "form" was slip of the brain; it is a report. Here is the entire code of the form. Problem occurs at the arrow. If the value of raOntvangst_d is #1/1/2049#, I supress the date fields raOntvangst_d and raTerug_d and show the text in mActueel at the same place.

This report is a copy of an existing report that does run without any problems, with just the following changes:
- different fields in the DoCmd.SetOrderBy statement
- different order of the fields in the report (fields sorted on are shown first)

Any suggestions appreciated.

Code:
'rptRapportaudits_LijstOpSD
Option Compare Database
Option Explicit
'==========================================================================

Private Sub Report_Open(Cancel As Integer)
DocumentKop.Caption = pubTekst1
Me.RecordSource = "pubQueryDef"
DoCmd.SetOrderBy "mNaam, raRealEnd_d"
Voet.Caption = "Afdruk: " & Format(Now(), "dddd, d mmmm yyyy hh:mm")
If (Len(pubOmgeving) <> 0) Then
  RapportNaam.Visible = True
End If
End Sub
'==========================================================================

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Select Case raAuditStatus_i
  Case 1
    mAuditStatus = "nog niet ontvangen"
    mAuditStatus.BackColor = 16777215
  Case 2
    mAuditStatus = "wacht op audit"
    mAuditStatus.BackColor = 65535
  Case 3
    mAuditStatus = "audit loopt"
    mAuditStatus.BackColor = 16777215
  Case Else
    mAuditStatus = "onbekend!!!"
    mAuditStatus.BackColor = 65535
End Select
mSTUDIENR = mod_FormatStudieNr(gStudienr)
mAuditSoort = pubRapportAuditSoort(raRapportAuditSoort_i)
raOntvangst_d.BackColor = 16777215
raTerug_d.BackColor = 16777215
If raDeadline_b = True Then
  raOntvangst_d.FontWeight = 700
  raTerug_d.FontWeight = 700
Else
  raOntvangst_d.FontWeight = 400
  raTerug_d.FontWeight = 400
End If

If raRealStart_d = #1/1/2049# Then
  mWerkelijk.Visible = True
  mWerkelijk = "Nog niet ingepland"
  raRealStart_d.Visible = False
  raRealEnd_d.Visible = False
Else
  raRealStart_d.Visible = True
  raRealEnd_d.Visible = True
  mWerkelijk.Visible = False
End If
If raOntvangst_d = #1/1/2049# Then
  mActueel = "Nog niet ingepland"
  mActueel.Visible = True
  raOntvangst_d.Visible = False
  raTerug_d.Visible = False '<<<<<<<<<<<<<<<<<< problem here
Else
  raOntvangst_d.Visible = True
  raTerug_d.Visible = True
  mActueel.Visible = False
End If

raRealEnd_d.BackColor = 16777215
If ((raOntvangst_d < Int(Now)) And (raAuditStatus_i = 1)) Then
  raOntvangst_d.BackColor = 65535 'geel (niet tijdig ontvangen)
Else
  If ((raTerug_d < Int(Now)) And (raAuditStatus_i > 1)) Then
    raTerug_d.BackColor = 65535 'geel (niet tijdig teruggegeven)
  Else
    If (raRealEnd_d > raTerug_d) Then
      raRealEnd_d.BackColor = 65535 'geel (gaat planning niet halen)
    End If
  End If
End If

End Sub
'==========================================================================
 
I've never heard of this type of error in a report. What view are you using? Is it Print Preview or other?

I would first (and always) prefix all control names with "Me." to avoid any confusion. If this doesn't remove the error, I would probably try rename the control and change the code. If that didn't work, I would probably try ignore the errors.

Duane
Hook'D on Access
MS Access MVP
 
Thank you for your suggestions; unfortunately they didn't solve the problem. Eventually I "solved" it, bij setting ForeColor of the fields I don't want to show to their BackColor, instead of setting their Visible poperty to False. Not very elegant, but it works,
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top