Page 1 of 2 12 LastLast
Results 1 to 40 of 52

Thread: Message Box if there are No Records in a Form

  1. #1

    Thread Starter
    Member
    Join Date
    Jan 2006
    Location
    Toronto, Canada
    Posts
    41

    Message Box if there are No Records in a Form

    Hi
    I am trying to get a Message Box if there are No Records in a Form, here is the code.
    thank you in advance
    Pretty

    VB Code:
    1. Private Sub Command40_Click()
    2. On Error GoTo Err_Command40_Click
    3. Dim stDocName As String
    4. Dim stLinkCriteria As String
    5. Dim intHolder As Integer
    6. intHolder = DCount("UnitAreaName", "qryMainDue")
    7. If intHolder > 0 Then
    8. stDocName = "frmDue"
    9. DoCmd.OpenForm stDocName, , , stLinkCriteria
    10. Else
    11. MsgBox "There are no records!"
    12. End If
    13. Exit_Command40_Click:
    14. Exit Sub
    15. Err_Command40_Click:
    16. MsgBox Err.Description
    17. Resume Exit_Command40_Click
    18. End Sub

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Message Box if there are No Records in a Form

    You are using Access VBA?You could write code in the Forms Load event and check for records in there.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: Message Box if there are No Records in a Form

    ?? when I try similar code.. it works fine

    VB Code:
    1. Dim intHolder As Integer
    2.     intHolder = DCount("ID", "Query1")
    3.     If intHolder > 0 Then
    4.         DoCmd.OpenForm "Form1"
    5.  
    6.     Else
    7.         MsgBox "No Records"
    8.     End If
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  4. #4

    Thread Starter
    Member
    Join Date
    Jan 2006
    Location
    Toronto, Canada
    Posts
    41

    Re: Message Box if there are No Records in a Form

    Yes i am using Access VBA.. I tried in FORM LOAD event but I am getting error msg saying "You entered an invalid argument in a domain aggregate function".

    Thanks

    Pretty

  5. #5
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Message Box if there are No Records in a Form

    Well you can open the forms recordset initially like static posted and check the records and then only open the form itf records exist.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  6. #6
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: Message Box if there are No Records in a Form

    well thats what she is doing...

    my guess is though.. the Dcount is returning > 0 thats why its opening the form..
    check to make sure your looking at the SAME data as the form is... and check to see if its really empty
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  7. #7
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Message Box if there are No Records in a Form

    Well I think the error is more related to the passing of a nullstring as the criteria and giving different recordset results. stLinkCriteria is never populated.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  8. #8

    Thread Starter
    Member
    Join Date
    Jan 2006
    Location
    Toronto, Canada
    Posts
    41

    Re: Message Box if there are No Records in a Form

    No I have no records in RecordSource (qryMainDue) ... still form is opening... i am confused here :-)
    By the way i just started working with VB Access, i am not an expert
    Static i tried ur code as well,, didnt work
    I have my Main switchboard named frmMainMenu and there i have my button "frmDue" (my Sub Form)...

  9. #9
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Message Box if there are No Records in a Form

    Can you describe the design of your form as I see now that there is a sub form involved. What recordset is tied to what form?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  10. #10

    Thread Starter
    Member
    Join Date
    Jan 2006
    Location
    Toronto, Canada
    Posts
    41

    Re: Message Box if there are No Records in a Form

    Main Form Called frmMainMenu (just switchboard) I have several buttons thats it, no record set.. one of the buttons called command40(no name:-). When user click on that i need my sub form (frmDue) to be open. but i need a Message Box if there are No Records in a Form.
    frmDue from recordsource qryMainDue.

    thanks for your time

  11. #11
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: Message Box if there are No Records in a Form

    alos.. put a breakpoint on this line:

    VB Code:
    1. If intHolder > 0 Then

    to add the breakpoint click in the gray column next to the line... it should add a dot in the column and highlight the line...

    now go back to the form and trigger the code.. (click the button)
    it should stop on the breakpoint...
    put your mouse over intHolder and it should give u a tooltip with the value of it...
    whats the value?
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  12. #12
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Message Box if there are No Records in a Form

    It should be qryMainDue then and is this an actual nested subform or just a secondary form?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  13. #13

    Thread Starter
    Member
    Join Date
    Jan 2006
    Location
    Toronto, Canada
    Posts
    41

    Re: Message Box if there are No Records in a Form

    i am getting a error msg saying "u cancelled the previous operation" :S i added the breakpoint its not even start trigger the code..

  14. #14

    Thread Starter
    Member
    Join Date
    Jan 2006
    Location
    Toronto, Canada
    Posts
    41

    Re: Message Box if there are No Records in a Form

    secondary form

  15. #15
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Message Box if there are No Records in a Form

    Can you zip and attach your db in a post?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  16. #16

    Thread Starter
    Member
    Join Date
    Jan 2006
    Location
    Toronto, Canada
    Posts
    41

    Re: Message Box if there are No Records in a Form

    its a separate form(frmDue) .. main swichboard doesnt have any forms only buttons

  17. #17

    Thread Starter
    Member
    Join Date
    Jan 2006
    Location
    Toronto, Canada
    Posts
    41

    Re: Message Box if there are No Records in a Form

    nooo i have 1000 records ... its confidencial

  18. #18
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Message Box if there are No Records in a Form

    how about removing all the records and confidential data?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  19. #19

    Thread Starter
    Member
    Join Date
    Jan 2006
    Location
    Toronto, Canada
    Posts
    41

    Re: Message Box if there are No Records in a Form

    still i have other coding for my other sub forms.... all i did using VB coding... i work for a bank i cant do that u know...

  20. #20

    Thread Starter
    Member
    Join Date
    Jan 2006
    Location
    Toronto, Canada
    Posts
    41

    Re: Message Box if there are No Records in a Form

    its ok i will find an other way to fix the problem... i am going to have empty form for now until i fix....

  21. #21
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Message Box if there are No Records in a Form

    Ok, its just hard to debug Access forms without seeing them.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  22. #22

    Thread Starter
    Member
    Join Date
    Jan 2006
    Location
    Toronto, Canada
    Posts
    41

    Re: Message Box if there are No Records in a Form

    hmm ok thanks

  23. #23
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: Message Box if there are No Records in a Form

    Citi?

    anyways.. u added the breakpoint and now it wont even work? u mustve changed something....

    When u open "qryMainDue" (from the database window) does it return results?
    is it using any params from open forms etc?
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  24. #24

    Thread Starter
    Member
    Join Date
    Jan 2006
    Location
    Toronto, Canada
    Posts
    41

    Re: Message Box if there are No Records in a Form

    no ididnt change anything i have same code as i have above.. if i just open qryMainDue i have no problem.. qryMainDue has criteria ..first it asks year from them user then the month.. then it gives them issues due on that specific month of the year...

  25. #25
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: Message Box if there are No Records in a Form

    so when u do the Dcount() does it ask for the criteria?

    Where is it getting the criteria from when u open the form?
    is the form bound to that query??

    as was said before.. hard to pinpoint without a db to play with.

    I used to work for Citigroup so I know allll about need for confidentiality...
    copy the database.. open up the copy and clear the tables of all confidential data.
    then zip and attach it or if u want.. PM it to me, that way it will not be "public"
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  26. #26

    Thread Starter
    Member
    Join Date
    Jan 2006
    Location
    Toronto, Canada
    Posts
    41

    Re: Message Box if there are No Records in a Form

    Did i say i work for Citi? i just said bank...

    DCount("UnitAreaName", "qryMainDue")... frmDue bounds to qry (qryMainDue).when i click the button on the Main switchboard, the form is not getting the qry "qryMainDue" (recordsource).. thats why its saying "You cancelled the previous operation" it doesnt read the qry criteria i think...just confused

  27. #27

    Thread Starter
    Member
    Join Date
    Jan 2006
    Location
    Toronto, Canada
    Posts
    41

    Re: Message Box if there are No Records in a Form

    if there is no criteria then the form working fine....

  28. #28
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: Message Box if there are No Records in a Form

    put a textbox in the main form.. have the user enter the criteria in the textbox then in the query criteria section

    =[Forms].[Form2].[Text1]

    something like that.. so it reads the criteria from the switchboard
    another method...

    create a public funtion in a module
    VB Code:
    1. Public Function GetCrit() As String
    2.  
    3. GetCrit = 5
    4.  
    5. End Function

    something along those lines... that can read public variables that u have set from the button click
    then just put this in the criteria field

    GetCrit()
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  29. #29

    Thread Starter
    Member
    Join Date
    Jan 2006
    Location
    Toronto, Canada
    Posts
    41

    Re: Message Box if there are No Records in a Form

    i knew the first method, but i didnt wnat to have txtbox in my swichboard.. i am going to try doing 2nd method u mentioned.. thank you

    Pretty

  30. #30
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: Message Box if there are No Records in a Form

    Just to explain it better:

    in a module put this:
    VB Code:
    1. Public sCrit1 As String
    2. Public sCrit2 As String
    3. Public sCrit3 As String
    4.  
    5. Public Function GetCrit1() As String
    6.     GetCrit = sCrit1
    7. End Function
    8. Public Function GetCrit2() As String
    9.     GetCrit = sCrit2
    10. End Function
    11. Public Function GetCrit3() As String
    12.     GetCrit = sCrit3
    13. End Function

    THen in your form set the variables before its called...
    VB Code:
    1. Private Sub Command40_Click()
    2. [B]    sCrit1 = "a"
    3.     sCrit2 = "b"
    4.     sCrit3 = "c"[/B]
    5.     On Error GoTo Err_Command40_Click
    6.     Dim stDocName As String
    7.     Dim stLinkCriteria As String
    8.     Dim intHolder As Integer
    9.     intHolder = DCount("UnitAreaName", "qryMainDue")
    10.     If intHolder > 0 Then
    11.     stDocName = "frmDue"
    12.     DoCmd.OpenForm stDocName, , , stLinkCriteria
    13.     Else
    14.     MsgBox "There are no records!"
    15.     End If
    16. Exit_Command40_Click:
    17.     Exit Sub
    18. Err_Command40_Click:
    19.     MsgBox Err.Description
    20.     Resume Exit_Command40_Click
    21. End Sub

    then u can use

    GetCrit1()
    GetCrit2()
    GetCrit3()
    in the criteria fields
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  31. #31

    Thread Starter
    Member
    Join Date
    Jan 2006
    Location
    Toronto, Canada
    Posts
    41

    Re: Message Box if there are No Records in a Form

    How do i get the user input ...
    VB Code:
    1. InputBox("Please enter year")

  32. #32
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: Message Box if there are No Records in a Form

    sCrit1 = Inputbox("Please Enter Year")
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  33. #33

    Thread Starter
    Member
    Join Date
    Jan 2006
    Location
    Toronto, Canada
    Posts
    41

    Re: Message Box if there are No Records in a Form

    error msg i am getting now "undefined function GetCrit1 in Expression"
    its time to leave now so i am going to try it tmr..
    many thanks ....
    your help is appreciated.

  34. #34
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: Message Box if there are No Records in a Form

    u put the functions in a module? (Made them public?)

    just like this? (PS.. I just noticed that I was not setting the function to the value so use this code in the module now)


    VB Code:
    1. Public sCrit1 As String
    2. Public sCrit2 As String
    3. Public sCrit3 As String
    4.  
    5. Public Function GetCrit1() As String
    6.     GetCrit1 = sCrit1
    7. End Function
    8. Public Function GetCrit2() As String
    9.     GetCrit2 = sCrit2
    10. End Function
    11. Public Function GetCrit3() As String
    12.     GetCrit3 = sCrit3
    13. End Function
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  35. #35

    Thread Starter
    Member
    Join Date
    Jan 2006
    Location
    Toronto, Canada
    Posts
    41

    Re: Message Box if there are No Records in a Form

    hmm thank you so much ... i am done :P Thanks a bunch Static and Robdog............

  36. #36
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: Message Box if there are No Records in a Form

    Cool. glad it works now... just a tidbit.. another way to do this that would reduce code:
    VB Code:
    1. Public sCrit(9) As String
    2.  
    3. Public Function GetCrit(cNum As Integer) As String
    4.     GetCrit = sCrit(cNum)
    5. End Function

    then u could set them line
    sCrit(0) = "Whatever"
    sCrit(1) = "This"

    then in the Query Criteria
    GetCrit(0)

    etc....

    also, if this thread is resolved now, please click thread tools > mark thread resolved so we all know its been answered Thanks!!!
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  37. #37

    Thread Starter
    Member
    Join Date
    Jan 2006
    Location
    Toronto, Canada
    Posts
    41

    Re: Message Box if there are No Records in a Form

    opps..one more question...
    when i have no records, the form working fine, i am getting the msg "there is not records", but when there are records (>0) then i am getting prompt 2 times, it asking year then month, again year and month?
    VB Code:
    1. Dim intHolder As Integer
    2. [B]    intHolder = DCount("UnitAreaName", "qryMainDue")
    3.     If intHolder > 0 Then
    4.     stDocName = "frmDue"
    5.     DoCmd.OpenForm stDocName, , , stLinkCriteria[/B]
    6.     Else
    7.     MsgBox "There are no records!"
    8.     End If
    i couldnt figure it out

  38. #38
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: Message Box if there are No Records in a Form

    what are u using this for? stLinkCriteria

    try just this:

    DoCmd.OpenForm stDocName
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  39. #39

    Thread Starter
    Member
    Join Date
    Jan 2006
    Location
    Toronto, Canada
    Posts
    41

    Re: Message Box if there are No Records in a Form

    no i am not using it (stlinkcriteria)
    ???:S

  40. #40

    Thread Starter
    Member
    Join Date
    Jan 2006
    Location
    Toronto, Canada
    Posts
    41

    Re: Message Box if there are No Records in a Form

    VB Code:
    1. Private Sub Command40_Click()
    2.     sCrit1 = "a"
    3.     sCrit2 = "b"
    4.     Dim stDocName As String
    5.     stDocName = "frmDue"
    6.     Dim intHolder As Integer
    7.     intHolder = DCount("UnitAreaName", "qryMainDue")
    8.     If intHolder > 0 Then
    9.     DoCmd.OpenForm stDocName
    10.     Else
    11.     MsgBox "There are no records!"
    12.     End If
    13. End Sub

Page 1 of 2 12 LastLast

Posting Permissions

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



Click Here to Expand Forum to Full Width