Creating a duplicate record using VBA

User avatar
HansV
Administrator
Posts: 78457
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Creating a duplicate record using VBA

Post by HansV »

Short Text, Date/time, Number and Yes/No fields don't have a text color.
Long Text fields can contain formatting if you set their Test Format property to Rich Text. I'm not sure you'd want that.

It might be better to add a Yes/No field to tblFinding that specifies whether a record was copied. You could then use this field in a conditional formatting rule for text boxes and combo boxes on sfrmFinding.
Best wishes,
Hans

duke_44
2StarLounger
Posts: 115
Joined: 07 Feb 2017, 13:31

Re: Creating a duplicate record using VBA

Post by duke_44 »

Thank you, I like the idea of adding a check box. Means my user may have some extra inputs but perfectly fine.

So....

I have added a check box into sfrmFinding to act as the YES/NO field. From there is it an IF statement where IF chkLeftOver = TRUE then set font of Finding to RED (I haven't looked up the proper syntax for this function yet)?

Am I close?

Chris

User avatar
HansV
Administrator
Posts: 78457
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Creating a duplicate record using VBA

Post by HansV »

The check box should be bound to a Yes/No field in tblFinding, otherwise it won't work. Let's say this field is also named chkLeftOver.

Select the text boxes and combo boxes whose font you want to change.
On the Format tab of the ribbon (under Form Design Tools), click 'Conditional Formatting'.
Click 'New Rule'.
Select 'Expression Is' from the dropdown under 'Format only cells where the'.
In the box next to it, enter

[chkLeftOver]=True

Click the font color dropdown and select red.
Click OK.
S3045.png
You do not have the required permissions to view the files attached to this post.
Best wishes,
Hans

duke_44
2StarLounger
Posts: 115
Joined: 07 Feb 2017, 13:31

Re: Creating a duplicate record using VBA

Post by duke_44 »

Works like a charm!

The formatting does not remain when exporting my data (Excel, PDF, etc.) or reporting from Access. Is there a means to keeping the font as RED all the time (so long as the check box is TRUE)?

User avatar
HansV
Administrator
Posts: 78457
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Creating a duplicate record using VBA

Post by HansV »

You can apply the same conditional formatting in a report based on tblFinding.
If you export the report to PDF, the conditional formatting should be preserved.
Best wishes,
Hans