Results 1 to 12 of 12
  1. #1
    jlgray0127 is offline Competent Performer
    Windows 2K Access 2000
    Join Date
    Oct 2011
    Location
    Central Illinois
    Posts
    187

    Forms and Conditional formats

    I am entering part numbers into a form. (table 1) Each time I enter a value, I want the form to look at table 2 and search for that same part number. If the record exsists, I want that record in the form to be highlighted. Any thoughts on how to do this?

  2. #2
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,610
    Can you give some clarification please.
    If the record exsists, I want that record in the form to be highlighted.
    The record in which form? Do you mean the current record of the form you are entering data in to?
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  3. #3
    jlgray0127 is offline Competent Performer
    Windows 2K Access 2000
    Join Date
    Oct 2011
    Location
    Central Illinois
    Posts
    187
    Yes. I am entering part numbers into table 1, via a form. If the part number is in my list, table 2, I want the field in the form (table 1) where I just entered the number to highlight yellow.
    I believe when I tab outta the record when I enter the number, that I can have it highlight the record if the number exsists on table 2...
    I will need to retain that info though, for future reference...

  4. #4
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,610
    Try this in the After Update event of your tex box:
    If DCount("[NameOfFieldInTable1]", "Table1", "[NameOfFieldInTable1]='" & Me.ActiveControl & "'") > 0 Then
    Me.ActiveControl.BackColor = 8454143 'yellow
    Else
    Me.ActiveControl.BackColor = 16777215 'white
    End If
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  5. #5
    jlgray0127 is offline Competent Performer
    Windows 2K Access 2000
    Join Date
    Oct 2011
    Location
    Central Illinois
    Posts
    187
    Doesn't there have to be a reference to table 2? I am not very good with code yet, so get confused very easily with it! lol
    I am great in access when it comes to all the predefined controls and making them work! This is definately above my head! I appreciate your help!

  6. #6
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,610
    Sorry, my mistake
    Should be:
    Code:
    If DCount("[NameOfFieldInTable2]", "Table2", "[NameOfFieldInTable2]='" & Me.ActiveControl & "'") > 0 Then
    Me.ActiveControl.BackColor = 8454143 'yellow
    Else
    Me.ActiveControl.BackColor = 16777215 'white
    End If 
    
    
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  7. #7
    jlgray0127 is offline Competent Performer
    Windows 2K Access 2000
    Join Date
    Oct 2011
    Location
    Central Illinois
    Posts
    187
    It works!!!! Thank you!!!!!

  8. #8
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,610
    Glad you have what you need .

    You may want to put the code in the form's OnCurrent event as well.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  9. #9
    jlgray0127 is offline Competent Performer
    Windows 2K Access 2000
    Join Date
    Oct 2011
    Location
    Central Illinois
    Posts
    187
    Ok. I will try that and see how it works. Again, thank you!

  10. #10
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,610
    Glad we have been able to help. Let us know how you get on.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  11. #11
    jlgray0127 is offline Competent Performer
    Windows 2K Access 2000
    Join Date
    Oct 2011
    Location
    Central Illinois
    Posts
    187
    Ok... now, I have this down. Now I want to try something else, using this same code, for another record in the form...

    If DCount("[NameOfFieldInTable2]", "Table2", "[NameOfFieldInTable2]='" & Me.ActiveControl & "'") > 0 Then
    Me.ActiveControl.BackColor = 8454143 'yellow
    Else
    Me.ActiveControl.BackColor = 16777215 'white
    End If

    Instead of changing the format, I want to run a macro that I wrote, but am not sure how to word the command? Anythoughts?

  12. #12
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,610
    Hi
    I don't really use macros, but you could try this line of code:
    Code:
    DoCmd.RunMacro "NameOfYourMacro"
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Import Excel and date formats
    By thart21 in forum Import/Export Data
    Replies: 1
    Last Post: 04-19-2011, 03:49 PM
  2. Queries; need assistance changing formats
    By 9944pdx in forum Queries
    Replies: 4
    Last Post: 01-28-2011, 05:56 PM
  3. two tables, different field formats, need to search
    By bairdgbaird in forum Queries
    Replies: 3
    Last Post: 09-23-2010, 08:50 AM
  4. Replies: 2
    Last Post: 08-27-2010, 10:11 AM
  5. Queries that Check field formats
    By mojers in forum Queries
    Replies: 3
    Last Post: 05-02-2010, 07:39 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums