Page 3 of 3 FirstFirst 123
Results 31 to 37 of 37
  1. #31
    JBros is offline Novice
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Posts
    21

    Hello,

    I've tried to put it as you indicated. It says now that there are a compilation error and redirects me to the VBA, saying there's an End With without a With, and highlighting the first statement. It may be something wrong with the code I've put which is the following:

    Click image for larger version. 

Name:	C22.PNG 
Views:	3 
Size:	13.6 KB 
ID:	29562

    There is actually a with sentence. I may not have understood you well in #28, as I deleted the 'onClick' function. Thank you very much.

  2. #32
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    That's odd. Same as June said, remove the With and End With - I also do not understand its purpose.

  3. #33
    JBros is offline Novice
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Posts
    21
    Wow it works now. I removed the With and End With and appeared another error saying the same with If. I added an additional 'End If' at the end (I'm not sure if it was necessary) and now it seems to work. The code ended up being this one:

    Code:
    Private Sub Company_Click()
    
            If (IsNull(Me!Id)) Then
                Beep
            Else
            If CurrentProject.AllForms("Company Detail").IsLoaded = False Then
                ' Form is closed
                DoCmd.OpenForm "Company Detail", acNormal, "", "[Id]=" & Me!Id, , acDialog
            Else
                ' Form is open
                Forms![Company Detail].Filter = "id=" & Me!Id
                Forms![Company Detail].FilterOn = True
                Forms![Company Detail].Requery
            End If
            End If
    
    End Sub
    I'm really happy to have it working right now, I really appreciate your help so thank you so much.

    As an additional thing, now that I have the events working, is there anyway to put the 'Company names' in the Subform inside 'Home' appear like an hyperlink? (Underlined, different color and that when you are on it the cursor changes)? Pretty much like it happens in Northwind sample database. I guess it might not be very difficult to do but I haven't find an effective way yet.

    Thank you very much again.

  4. #34
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Tips on your code - the line-up of each line needs to be indented, then you can easily see at a glance when there is an End If missing. Access does not care about line indentation, but it helps us humans a lot!

    Code:
            If (IsNull(Me!id)) Then
                Beep
            Else
                If CurrentProject.AllForms("Company Detail").IsLoaded = False Then
                    ' Form is closed
                    DoCmd.OpenForm "Company Detail", acNormal, "", "[Id]=" & Me!id, , acDialog
                Else
                    ' Form is open
                    Forms![Company Detail].Filter = "id=" & Me!id
                    Forms![Company Detail].FilterOn = True
                    Forms![Company Detail].Requery
                End If
            End If
    That missing End If was most probably the problem all along, even with the "With/End With" - I missed it, however!

  5. #35
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    In the properties for Company there is one called "Is Hyperlink" Change this to Yes and see if that is what you are after.

  6. #36
    JBros is offline Novice
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Posts
    21
    Yes, identation can be very useful, I'll fix it!

    And yes, the hyperlink thing was that easy. Thank you very much for all your help!!!

  7. #37
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    You're welcome!

    (Note: that error in post #31 was caused by the missing End If. The code was in the middle of an IF statement and it was presented with an END WITH - that is why it gave an error. The last thing it was told was IF and was expecting the END IF. Just for future reference.)

Page 3 of 3 FirstFirst 123
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 3
    Last Post: 05-28-2017, 07:36 PM
  2. Replies: 1
    Last Post: 01-21-2015, 02:02 PM
  3. Access macro vs. excel macro
    By twckfa16 in forum Macros
    Replies: 3
    Last Post: 01-07-2015, 03:44 PM
  4. Replies: 7
    Last Post: 03-27-2014, 11:47 AM
  5. Replies: 0
    Last Post: 03-04-2011, 10:28 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