Message Box/Coding issue

caferacer

Registered User.
Local time
Today, 09:45
Joined
Oct 11, 2012
Messages
96
Hi All,

I am using the code below to highlight to the DB user that a piece of equipment is available from two suppliers or vendors.

I am using a form named Equipment which has a checkbox named MultipleSource and Label51 embedded. The form (Equipment) is used both independently and also as as subform.

When using the Equipment form independently on its own, the code works fine, but when the Equipment form is used as a subform, when DCount is >1 the code runs fine, apart from the MsgBox pops up consequitively 4,5 or sometimes even 6 times?

I have disabled other code to see if there is any improvement, but no change.

Any ideas?

Thanks in advance.

Mark

(Access2003).

If DCount("*", "tbl VendorEquipmentJUNCTION", "[EquipmentID] = " & Me!EquipmentID) > 1 Then
Me.MultipleSource = -1
Me.Label51.FontBold = True
Me.Label51.ForeColor = vbRed
Me.Label51.BackStyle = 1
Me.Label51.BackColor = vbYellow
Command68.Visible = True
MsgBox "Multi Source item"

Else

Me.MultipleSource = 0
Me.Label51.FontBold = False
Me.Label51.ForeColor = vbBlack
Me.Label51.BackStyle = 0
Command68.Visible = False

End If
 
Access maintains only a single set of properties for forms in continuous or datasheet view regardless of how many records are displayed so customizing the properties of any field actually affects all visible rows.

Conditional formatting is a better choice. It is more limited but should work in this case. You didn't say what event you are using to set these values but you should change to the Current Event or don't display a message box.
 
Hi Pat,

Yeah sorry about the important lack of info - it is the forms Current Event which the code is called from.

The form is displayed as a Single Form, so will your opening comment still influence this? Should I still look at conditional formatting?

Thanks for you help.

Regards

Mark.
 
I mis-read your statement. I was reading it as single form to continuous form but I see now it is single form to subform.

The fact that the message box is coming up multiple times is puzzling. That shouldn't happen in single form view which is why I though it was a continuous form.

Put a stop in the code and follow step by step to see why the code is looping.
 

Users who are viewing this thread

Back
Top Bottom