Various labels on form become bold when click command button - no code entered to make them bold (1 Viewer)

chrisjames25

Registered User.
Local time
Today, 13:36
Joined
Dec 1, 2014
Messages
379
HI. I have a userform that when it opens all looks good and all my labels on form are not bold.

I enter a batch number at the topand then click a command button to pull in the data to the form relating to the batch number. On clicking this command button numerous of my controls labels turn bold for no explained reason.

PLease see attached images showing the change.

Th
After Clicking command button.JPG
Before Clicking command button.JPG



The only code in the command button is as follows:

Code:
Private Sub Cmd_EnterPottingData_Click()

Dim msg As String
Dim style As String
Dim title As String
Dim response As String
Dim mystring As String
Dim field As String
Dim Source As String
Dim criteria As String

field = "BatchNo"
Source = "Tbl_PottingData"

If Len(Me.Txt_BatchNo.Value & vbNullString) = 0 Then
Exit Sub
Else

criteria = field & "= " & Me.Txt_BatchNo

End If

'##############################################
' TEST VALID BATCH NO.
'##############################################

If DCount(field, Source, criteria) = 0 Then
        msg = "This batch number does not exist within the database"
        style = vbOKOnly + vbExclamation
        title = "Batch No. Input Error"

        response = MsgBox(msg, style, title)
        Me.Txt_BatchNo.Value = "XXXX"
        Me.Txt_BatchNo.SetFocus
        Exit Sub
End If

'################################################
' If VALID populate sheet

Me.Form.Requery
Me.Cbo_Category = Me.Bound_Category
Me.Cbo_Variety = Me.Bound_Variety
Me.Cbo_Genus.Requery
Me.Cbo_Genus = Me.Bound_Genus
Me.Cbo_Customer = Me.Bound_Customer
Me.Cbo_Supplier = Me.Bound_Supplier
Me.Cbo_Potsize.Requery
Me.Cbo_Potsize = Me.Bound_PotsizeID
Me.Cbo_Compost = Me.Bound_CompostID
Me.Cbo_Nursery = Me.Bound_NurseryID

Me.Cbo_Greenhouse.Requery
Me.Cbo_Greenhouse = Me.Bound_GreenhouseID

Me.Txt_QtySupplied = Me.Bound_QtySupplied
Me.Txt_QtyPerPot = Me.Bound_QtyPerPot
Me.Txt_TotalOutput = Me.Bound_Output
Me.Txt_SupplierNo = Me.Bound_SupplierNo

Me.Lbl_Plug.FontBold = False
'Me.Cbo_Category.SetFocus



Me.Txt_QtyPotted.SetFocus

'UnlockData



'Me.Form.Requery
End Sub

I cant see how this could effect labels in the form. Is this a bug. I could do a workaround of tall all labels to bold = false but would rather try to understand why this is occurring.

Thanks in advance
 

GPGeorge

Grover Park George
Local time
Today, 05:36
Joined
Nov 25, 2004
Messages
670
Maybe my old eyes are not good enough to spot the difference, but I can't really tell the difference from these screenshots.

But that aside, look at conditional formatting on the controls to which the labels apply.
 

Gasman

Enthusiastic Amateur
Local time
Today, 13:36
Joined
Sep 21, 2011
Messages
10,546
Not all the bold labels are highlighted, making it somewhat confusing.
Upload the DB with enough data to see the problem.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 07:36
Joined
Feb 28, 2001
Messages
22,799
Was any part of that form constructed using Layout frames? And if so, were those particular controls in the same layout frame as the control that appears to have focus (i.e. Qty Potted - in the top exhibit for your question)?
 

jdraw

Super Moderator
Staff member
Local time
Today, 08:36
Joined
Jan 23, 2006
Messages
14,318
I agree with Paul/gasman-- please post a copy of the database with data to highlight the issue.
 

chrisjames25

Registered User.
Local time
Today, 13:36
Joined
Dec 1, 2014
Messages
379
Quite hard to strip back the database to post as some sensitive docs on there. Will see what can do. It is odd becaue only certain controls change font to bold.
 

Gasman

Enthusiastic Amateur
Local time
Today, 13:36
Joined
Sep 21, 2011
Messages
10,546
Well try a new db and import just what is needed into that and see if it still happens.
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 08:36
Joined
Feb 19, 2002
Messages
36,296
Why are you using .Requery to save a record?
Why are you copying values between the two sets of variables? If your form is bound, Access is handling all the data for you.
 

Auntiejack56

Registered User.
Local time
Today, 22:36
Joined
Aug 7, 2017
Messages
156
Looks like you are highlighting errors on the form by setting the label on the error field to red and bold, n'est-ce pas?
So I suspect that when you click the button, the Lostfocus or Exit event is firing for the BatchNo field, and that is where the error is occurring. Your command button code looks alright, but your code to highlight the errors (which probably scans the whole form) is going haywire.
That is, unless it's the conditional formatting as per the Doc's note above.
Put some breaks anywhere that Bold is being set, and see what triggers it.
Jack
 

chrisjames25

Registered User.
Local time
Today, 13:36
Joined
Dec 1, 2014
Messages
379
Why are you using .Requery to save a record?
Why are you copying values between the two sets of variables? If your form is bound, Access is handling all the data for you.
Hi ya. NOt requering to save a record. It is set up to load 1 record so the database will search the number i enter in a txt box and that will bring back 1 record. I then enter the additional information and then click another command button that saves the data.

I will upload database shortly
 

chrisjames25

Registered User.
Local time
Today, 13:36
Joined
Dec 1, 2014
Messages
379
PLease see attached DB.

THe form in question is Frn_batchresults. If you enter batch 5002 in top text box and click adjacent command button you will see the bold effect happen on some of the textboxes. Oddly it looks like only the textboxes that are left empty rather than populated. The boldness seems to happen at forms.requery.
 

Attachments

  • Potting Database - amended.accdb
    6.8 MB · Views: 53

KitaYama

Active member
Local time
Today, 21:36
Joined
Jan 6, 2022
Messages
432
Nothing changes for me. Before and after clicking the button, labels font weight are the same.

2.png
 

chrisjames25

Registered User.
Local time
Today, 13:36
Joined
Dec 1, 2014
Messages
379
How weird. I'll try on a pc at home and see if i get same result as you.

I notice all your fonts are different on your screen also. Is this cos i have a setting that allows default font to be pciked up?
 

Users who are viewing this thread

Top Bottom