(1) I do not remember how the ) got there. I do remember removing it from the form. I did not remove it from the subform.
(2) I deleted the old subform and created a new subform with the control named BkPg.
(3) The backcolor from the Conditional Expression is working.
(4) Debug.Print...
I do not know how to create a query to show all names on the controls on the form. I can click through the form in layout mode and look at the control names.
There is a subform on the form that references the control BkPg within the same query as the form.
Name BOOK-PAGE-2012)
Label Name...
I created the sub by creating a Before Update Event Procedure on the form.
Private Sub BOOK_PAGE_2012__BeforeUpdate(Cancel As Integer)
Dim sBkPg As String
Debug.Print Me.[BkPg].Value 'check the value since it might not be set
Let sBkPg = DLookup("[BkPg]", "qry_copyrequest", "[BkPg] = '" &...
I added Option Explicit and removed Option Compare Database.
I ran Debug.Print Me.[BkPg].Value in the immediate window.
I am still getting the Compile Error "Variable not yet created in this context."
Is it wrong to have a control named BkPg ? The Conditional Formatting Expression did not work...
What a great idea. I cannot step through the code.
Private Sub BOOK_PAGE_2012__BeforeUpdate(Cancel As Integer)
Dim sBkPg As String
Debug.Print Me.[BkPg].Value 'check the value since it might not be set
Let sBkPg = DLookup("[BkPg]", "qry_copyrequest", "[BkPg] = '" & Me.BkPg & "'")
MsgBox...
Andrzejek asked "What is the Let?" I have no idea. It was contained in the code posted on Stackoverflow by "Rick."
I was thinking, "it works!" But, the VBA code does not have any method described to change the color. What changed was renaming the control source.
I tried DLookup code I found on Stackoverflow. I modified it to fit my ACCDB.
Option Compare Database
Private Sub BOOK_PAGE_2012__BeforeUpdate(Cancel As Integer)
Dim sBkPg As String
Let sBkPg = DLookup("[BkPg]", "qry_copyrequest", "[BkPg] = '" & Me.BkPg & "'")
MsgBox "This Book & Page already...
Duane:
Wow! Thank you for going to such extremes.
As for the background: I had set the background to Red and Text to Bold:White.
Now, I have renamed the fields. BOOK-PAGE-2012 is now BkPg. Still, no formatting when duplicates exist.
I have tried the following code which did not work...
Duane:
Again, thank you for trying to help with this issue. I checked the data which was input, wondering if special characters (i.e. the "-") made a difference. It did not.
After entering a value without special characters, the expression is still not evaluating for a duplicate.
I...
I am getting no error. I set the ID to turn red if n>1. And, the background should turn red if the record BOOK-PAGE-2012 is a duplicate.
I checked the record and there are no spaces in 71-151 in either the new record or the original record.
Duane: Thank you very much. This code is not working for me. I have copied the code into the expression exactly.
I applied the same formatting structure on the field RequestID which is a Number, Double. That doesn't work either.
qry_copyrequest:
SELECT tbl_copyrequest.ID...
I have an MS Access form that is based on a query. I want to apply conditional formatting to highlight the field on the form if the data is already in the dataset.
the query name is qry_copyrequest.
the table name is tbl_copyrequest
the field with the duplicates is BOOK-PAGE-2012
the...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.