Results 1 to 7 of 7
  1. #1
    tggsun is offline Novice
    Windows XP Access 2007
    Join Date
    Dec 2011
    Posts
    11

    VB has problems

    Hello,
    This is my first time to write VB code. I want to open a new form to enter data if I choice a specific value for a field from a dropdown list. So I wrote the following VB code:

    Private Sub Combo78_AfterUpdate()
    if FATALISM_Q6="Accu"
    then DoCmd.OpenForm "Accu"
    End If
    End Sub

    This one has problem to be used since it can not pass VB editor. But I don't know how to figure it out. Is there any one can tell me how to figure that out?



    Many Thanks........!
    DD sf

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,640
    Try:

    Code:
    if FATALISM_Q6="Accu" then 
      DoCmd.OpenForm "Accu"
    End If
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Where is FATALISM_Q6 coming from? Should it read Me!Combo78 instead?

    (Hint Give your controls names that make sense, Combo78 means nothing and will cause you confusion in time, especially if you start adding multiple combo's)

  4. #4
    tggsun is offline Novice
    Windows XP Access 2007
    Join Date
    Dec 2011
    Posts
    11
    thank you all. it works now.
    DD sf

  5. #5
    tggsun is offline Novice
    Windows XP Access 2007
    Join Date
    Dec 2011
    Posts
    11
    Hi guys,
    the following VB works fine.
    Private Sub Combo78_AfterUpdate()
    If Combo78 = "Accu" Then
    DoCmd.OpenForm "Accu"
    End If
    If Combo78 = "Audit" Then
    DoCmd.OpenForm "Audit"
    End If
    End Sub

    I want to add more functions on this:
    1). when VB open a window, I need to automaticly clear/or setup a field as empty of the row. (say field_empty="")
    2). when I need to close the opened form, I need to automatical save the values which I entered.
    Thanks,
    DD sf

  6. #6
    tggsun is offline Novice
    Windows XP Access 2007
    Join Date
    Dec 2011
    Posts
    11
    Also want to know if there is a reference book that can let me check out those VB command. And/or is there any good book for training?
    Thanks,
    DD sf

  7. #7
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    1) Depends what your form looks like - is it bound to a table? Is it columnar or datasheet? If it is bound to a table and you are going to a new reocrd then it will automatcally be empty (null)

    2) It is automatically saved as soon as you leave the record - if it is already bound to a table

    I don't know of any good book - VBA for Dummies?

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

Similar Threads

  1. IIF Problems
    By suverman in forum Queries
    Replies: 3
    Last Post: 05-23-2011, 02:22 AM
  2. problems please help
    By stryder09 in forum Access
    Replies: 1
    Last Post: 02-15-2011, 02:24 PM
  3. Workgroup Problems
    By allykid in forum Security
    Replies: 3
    Last Post: 07-13-2010, 03:04 AM
  4. Several problems
    By Bergh in forum Access
    Replies: 1
    Last Post: 05-30-2010, 03:56 AM
  5. OLE problems how to fix
    By miziri in forum Access
    Replies: 7
    Last Post: 04-29-2010, 06:18 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