Page 1 of 2 12 LastLast
Results 1 to 15 of 26
  1. #1
    glen is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jul 2012
    Posts
    171

    RecordSource issue?

    I need help regarding this database which i shown in attachment.
    means if combobox if Deparment is emty then combobox of Location and subform should be empty.


    I need the proper code for this.Thanks

  2. #2
    Robeen is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Mar 2011
    Location
    Tulsa, Oklahoma.
    Posts
    1,596
    In the After Update Event of the Combo Box -> you can put something like this:
    If Me.ComboBoxDepartment = "" Then '[Or - you may need If Me.ComboBoxName Is Null]
    Me.ComboBoxLocation.SetFocus
    Me.ComboLocation.Text = ""
    End If

  3. #3
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    To cover both ZLS ("") and Null you can use: If Len(YourControl & "") = 0 Then

  4. #4
    glen is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jul 2012
    Posts
    171
    In after update event there is already Embedded Macro.How I can add Event procedure too?

  5. #5
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    What is the embedded macro doing?

  6. #6
    glen is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jul 2012
    Posts
    171
    Quote Originally Posted by RuralGuy View Post
    What is the embedded macro doing?
    Bcoz I created Combobox in this procedure.
    see attached.

  7. #7
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Convery the Macro to VBA and we can show you what to add. http://www.btabdevelopment.com/ts/de...aspx?PageId=91

  8. #8
    Robeen is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Mar 2011
    Location
    Tulsa, Oklahoma.
    Posts
    1,596
    RG - thanks for that link!
    I often run into embedded Macros that I inherited here at work & I like that I can convert them to VBA & tweak them in an environment I feel I have more flexibility in.

  9. #9
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    A Combobox can only be 'empty' when no selection has been made from it, or when a selection made has been deleted. Once a selection has been made, you cannot scroll the Combobox and select a blank item again.

    So, in this kind of Search Form, a pretty standard approach is to go to a New Record when the Form is first Loaded. If you want the Record to go back to being 'blank,' if the user deletes the Combobox selection, you can do the same thing in the AfterUpdate event of the Combobox, when it's 'empty."

    Code:
    Private Sub Form_Load()
      DoCmd.GoToRecord , , acNewRec
    End Sub
    
    
    Private Sub ComboName_AfterUpdate()
     
     If Nz(Me.ComboName, "") = "" Then
      DoCmd.GoToRecord , , acNewRec
     End If
      
    End Sub

    Linq ;0)>

  10. #10
    glen is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jul 2012
    Posts
    171
    Quote Originally Posted by Missinglinq View Post
    A Combobox can only be 'empty' when no selection has been made from it, or when a selection made has been deleted. Once a selection has been made, you cannot scroll the Combobox and select a blank item again.

    So, in this kind of Search Form, a pretty standard approach is to go to a New Record when the Form is first Loaded. If you want the Record to go back to being 'blank,' if the user deletes the Combobox selection, you can do the same thing in the AfterUpdate event of the Combobox, when it's 'empty."

    Code:
    Private Sub Form_Load()
      DoCmd.GoToRecord , , acNewRec
    End Sub
    
    
    Private Sub ComboName_AfterUpdate()
     
     If Nz(Me.ComboName, "") = "" Then
      DoCmd.GoToRecord , , acNewRec
     End If
      
    End Sub

    Linq ;0)>
    Thank you very much you really solved my this problem.
    But I request Moderators that plz don't close or put in solved categories this thread. bcoz I have to ask some more codes in this thread.Thanks

  11. #11
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Glad we could help, but unless you have further questions regarding this specific problem, you need to start a new thread with an appropriate title.

    Good luck with your project!

    Linq ;0)>

  12. #12
    glen is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jul 2012
    Posts
    171
    when I am trying to open my form it gives the attached error/

  13. #13
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Does your project compile without errors?

  14. #14
    glen is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jul 2012
    Posts
    171
    Quote Originally Posted by RuralGuy View Post
    Does your project compile without errors?
    yes sir it compile without errors.

  15. #15
    glen is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jul 2012
    Posts
    171
    Plus: when I restart my database it start working.
    then again I close and restart not working again.
    sometime working sometime not.

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. RecordSource sql stays
    By rashima in forum Forms
    Replies: 0
    Last Post: 04-20-2012, 05:56 AM
  2. recordsource - inquiry
    By myboii1984 in forum Forms
    Replies: 4
    Last Post: 04-02-2012, 08:11 AM
  3. RecordSource Error
    By scampbell in forum Programming
    Replies: 7
    Last Post: 11-10-2011, 11:28 AM
  4. Export Recordsource
    By Paul H in forum Reports
    Replies: 2
    Last Post: 10-27-2011, 01:47 PM
  5. RecordSource help
    By mann2x in forum Access
    Replies: 3
    Last Post: 10-05-2010, 06:44 PM

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