Results 1 to 11 of 11
  1. #1
    2 Star Lounger
    Join Date
    Sep 2007
    Location
    Chatham, Kent, England
    Posts
    214
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Wild Cards (2000)

    Afternoon Loungers

    I have a form which list details of documents including document type, document name and site name.

    However, some of the document types are generic and there is no site name associated with it. I've made the site name tex box not visible when the document type text is "Generic Method Statement" using the following code:

    Me!DocType.SetFocus
    If Me!DocType.Text = "Generic Method Statement" Then
    Me!SiteName.Visible = False
    End If

    Trouble is, there are other generic documents. So is there a way of coding a wild card like "Generic *" Or do I have to code each generic document type separately?

    Regards

    Graeme

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Wild Cards (2000)

    You don't need to set the focus to the text box if you don't use the Text property. VBA has a Like operator that works the same way as Like in queries. You can use this:

    <code>Me!SiteName.Visible = Not (Me!DocType Like "Generic*")</code>

  3. #3
    2 Star Lounger
    Join Date
    Sep 2007
    Location
    Chatham, Kent, England
    Posts
    214
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Wild Cards (2000)

    Brilliant!

    Thanks

  4. #4
    2 Star Lounger
    Join Date
    Sep 2007
    Location
    Chatham, Kent, England
    Posts
    214
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Wild Cards (2000)

    I've now put the same code in a combo box on another form used for entering a new document into the database, in the after update event of the Doc Type combo box:


    Private Sub DocTypeID_AfterUpdate()

    Me!SiteID.Visible = Not (Me!DocTypeID Like "Generic*")

    End Sub


    So that if a generic document type is selected then the site name combo disappears, since it's not required.

    Any clues as to why the code doesn't work in this instance?

    Regards

    Graeme

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Wild Cards (2000)

    If the combo box has Column Count > 1, and the first column width is 0, the actual value of the combo box is not the text you see, but the value of the hidden first column.

    If so, use this:

    Me!SiteID.Visible = Not (Me!DocTypeID.Column(1) Like "Generic*")

    Columns of a combo box are numbered starting with 0, so Column(1) is actually the second column.

  6. #6
    2 Star Lounger
    Join Date
    Sep 2007
    Location
    Chatham, Kent, England
    Posts
    214
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Wild Cards (2000)

    Hans

    Works lovely, of course!

    Perhaps this needs a new thread in the VB forum but I'll put it here anyway.

    I've read a lot over the last year, in various books, on VBA, Access Basic and VB and have a fair understanding of the structure of a database and the code behind it. Where I feel weak is with the syntax of the code and the correct way to phrase the statements within the If Thens and the Do Whiles.

    Do you have any suggestions for where to find reading material which will address this?

    Regards

    Graeme

  7. #7
    Super Moderator
    Join Date
    Aug 2001
    Location
    Evergreen, CO, USA
    Posts
    6,624
    Thanks
    3
    Thanked 60 Times in 60 Posts

    Re: Wild Cards (2000)

    I would suggest you try to obtain a copy of the book "Beginning Access 2000 VBA" - it's one of the best on the subject, and VBA has different flavors depending on the application you are working with. You should be able to find it on Amazon if you search for Access and VBA.
    Wendell

  8. #8
    2 Star Lounger
    Join Date
    Sep 2007
    Location
    Chatham, Kent, England
    Posts
    214
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Wild Cards (2000)

    Thanks Wendell

    I'll have a look at Amazon when I get home tonight. And would this book be of equal value with respect to Visual Basic generally?


    Regards

    Graeme

  9. #9
    Super Moderator
    Join Date
    Aug 2001
    Location
    Evergreen, CO, USA
    Posts
    6,624
    Thanks
    3
    Thanked 60 Times in 60 Posts

    Re: Wild Cards (2000)

    The syntax of VBA and VB are virtually identical, but working with objects in one versus the other is quite different. In VB you can build an application with a data base back-end that uses the Jet engine (or SQL Server or some other database), but the process is quite different from doing so with Access. For example, forms in VB work rather differently from forms in Access (and have significantly less function, so that development takes considerably longer). On the other hand, if you want peak performance, VB may well be the best choice. There is some commonality in the way recordsets are manipulated, so that part would apply to both. Hope this helps.
    Wendell

  10. #10
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Wild Cards (2000)

    Look for O'Reilly's book, VB & VBA in a Nutshell. This is a language reference that gives you the basic syntax for VB/VBA but is not application specific. You still need an Access-specific book like the one Wendell recommended.
    Charlotte

  11. #11
    2 Star Lounger
    Join Date
    Sep 2007
    Location
    Chatham, Kent, England
    Posts
    214
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Wild Cards (2000)

    Thanks Charlotte

    <A target="_blank" HREF="http://www.amazon.co.uk/exec/obidos/ASIN/1565923588/qid=1089101178/sr=1-1/ref=sr_1_2_1/026-9527518-8150814">

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •