Results 1 to 2 of 2
  1. #1
    mseeker22 is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Jun 2011
    Posts
    35

    OnClick Cmd Button vs Image

    I have a strange little problem with the OnClick() command when using an Image instead of a Command Button.

    Originally I had a code working fine from a Cmd button but changed it to an image for aesthetic reasons and now it doesn't work properly.

    The set up is:

    Continuous form listing customers details (See image attached)

    The problem occurs when this next piece of code runs (I think!)

    As I click the button I can see the Customer Number in the TxtHiddenCN field change to the correct Customer Number for a split second and then it returns to the customer number that happens to be at the top of the customer list.

    As a result the next form that opens uses the Customers details that were at the top of the search results and not customer I selected.

    Code:
    'Customer Search Form
    Private Sub DiaryImage_Click()
            Me.TxtHiddenCN.SetFocus
            Me.TxtHiddenCN.Text = [Forms]![F_Booking Customer Search].[Customer Number]
            DoCmd.OpenForm "Customer Search Query"
    End Sub
    Oh, there is a Customer number field on each record as well, this is where the TxtHiddenCN is getting its data from . . . the field is visible but text is white and the column width has been reduced significantly so it can't actually be seen. I put the TxtHiddenCN in originally to make sure the code was doing what it was supposed to (i.e. actually see what customer number was being selected) and I never changed it . . . theoretically though the code should work exactly the same using just the original Customer Number field.

    Is there something specific that works differently when assigning code to an image as opposed to a cmd button . . . Help :-/

    Luke

  2. #2
    boblarson is offline --------
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    1,272
    My suggestion is to still use a command button, but set its property called TRANSPARENT to YES and overlay the image with it (button on TOP of the image). You'll still have the image but you can use the button's click event to handle the click.

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

Similar Threads

  1. make fields visible onclick() button
    By rivereridanus in forum Programming
    Replies: 4
    Last Post: 06-25-2012, 11:08 PM
  2. Change Value using Button OnClick
    By nchesebro in forum Programming
    Replies: 1
    Last Post: 06-23-2011, 02:47 AM
  3. Onclick event
    By tmcrouse in forum Forms
    Replies: 3
    Last Post: 09-18-2010, 01:10 PM
  4. Replies: 1
    Last Post: 07-27-2010, 02:27 PM
  5. Set onclick via VBA
    By Gerry in forum Programming
    Replies: 6
    Last Post: 04-19-2010, 09:23 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