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

Main form appears with white background

Status
Not open for further replies.

F2F4

Programmer
Oct 13, 2008
11
CA
When opening a form containing a subform I check to see whether a date field is filled in. If not filled in then my message box says field is blank. This causes the main form to appear white while the subform is normal. The effect dissapears after clicking the message box ok. It's annoying.
 
Use the Load event instead of the Open ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
just tried same code in either load event for the form or subform - just received different forms of white screen

For load event on subform - entire screen white
For load event on main form - main form top and bottom white - subform normal color
 
G'day,

Are you using the subform or main form open/load event? You should be putting it on the main form even if it's checking a value in a subform :

Code:
if isdate(forms!MyForm!SubformName.form!MyDateField) then
   'Good, do nothing
else
   Msgbox("Needs Date")
endif

If that doesn't work could you paste your code pls?

Just wondering why you're doing this though? If you use a default value for the date then you know it's always going to have a value. If you're not then you know it's going to be blank so why tell the user before they've even had the chance to fill in a value?

Validation generally happens when a user tries to navigate away from a record.

Hope this helps,

JB
 
Hi JB

Yes I have my code in the on load event in the main form. I have substituted the isdate function rather than isnull function as per your suggestion - this still results in a white main form when msgbox first displays.

Rationale for checking for existence of date on entry is that customer executes a rental calculation based on the existence of this date. Not that the rental calculation is done right away. They just wanted a reminder upon entry that the field hadn't been filled in yet.

Code is as follows:

For the main form

Private Sub Form_Load()
If IsDate(Forms!frmjobsiteb!StartRent) Then
'do nothing
Else
MsgBox "1st Bin Site is Blank"
End If
End Sub

Private Sub Form_Open(Cancel As Integer)
DoCmd.Maximize
Forms!frmjobsiteb!frmJobDetailsB.Requery
End Sub


For the sub form

Private Sub Form_Open(Cancel As Integer)
On Error GoTo Err_Form_Open
DoCmd.Maximize
Exit_Form_Open:
Exit Sub
Err_Form_Open:
MsgBox Err.Description
Resume Exit_Form_Open
End Sub

*Note
Both the main form and the sub form are built on single table queries. The parent child link Between form and sub form is a single field JobSiteID. The main form is called from a prior customer screen and the open form criteria to call the main form is based on a combination of CustomerID (type=long) and JobSiteAddress (type=string). I am trying to think of any abnormalities but can't come up with any other than the message box is causing a problem with how the screen sequence refreshes (or not). Take out the message box and the problem goes away.

F2F4

 
G'day F2F4,

Load is fine

OnOpen - Remove the requery line, not required as the form is only now opening and you have a link in place this will be automatic for you. I think this is the drama.

Sub OnLoad - Remove entirely, not required.

Hopefully that'll get you rockin mate,

JB
 
JBinQLD
Ok Done - in the OnOpen event main form - I have removed the requery line - Forms!frmjobsiteb!frmJobDetailsB.Requery

However the problem persists - Main form appears with white background when the form/subform opens with the msgbox awaiting an ok click

I could remove the onLoad statement -

Private Sub Form_Load()
If IsDate(Forms!frmjobsiteb!StartRent) Then
'do nothing
Else
MsgBox "1st Bin Site is Blank"
End If
End Sub

However where/when would I remind the user that the StartRent date field is blank?

Open to any suggestions

F2F4
 
In the Current event ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
PHV option is good - on current runs each time you move from one record to another.

However, in the interests of a decent UI (User Interface) I'd suggest not msgbox'ing at all - when you message box a user every time they move record they become very nonchalant and ust habitutally click ok or hit enter cos they learn to expect it.

Maybe in the oncurrent event look at something like setting the .color property to red, or maybe an "Update Rental Calculation" button that does the check before displaying result.

The best way is to ask the person who will be using it - believe me, they certainly wont want it on open of the form!

Good luck, JB



 
I will go with asking client "Is the msgbox really necessary or can we just use color changes instead" Thanks to JBinQLD / PHV for the help.

Close Thread

F2F4
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top