How to run a function (which pings the IP_Address field value) on a continuous report

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • RaffaEl13
    New Member
    • Jun 2013
    • 5

    #1

    How to run a function (which pings the IP_Address field value) on a continuous report

    Hi, I already search on the web but as I'm a beginner in VBA I didn't find the specific answer to my question. In fact I have a DB with Printer and I would like to display a list of them in a continuous form (form not a report sorry for the title) and have a ping status on each row. I already have a function wich ping the IP_Address value and return a True or False. This obviously works well on a form with just one printer and then one IP_Address value, but not in the continuous form where I have a list of IP Addresses. How can I run this function on each IP Address value in the continuous form (in the purpose to get the True/False value if it ping and modify an unbound field to indicate if the printer ping)? I hope it is clear. Thank you very much in advance.
    Last edited by zmbd; Jun 26 '13, 12:11 PM. Reason: [RaffaEl13; {error on the title}] [Z{Fixed the title per post}]
  • zmbd
    Recognized Expert Moderator Expert
    • Mar 2012
    • 5501

    #2
    Fixed your title per your post.

    Your function should refer to the control on your form that has the IP address (say it's named "txt_ctrl_print erip") and be entered into the control source of {unbound control} (say it's named "txt_ctrl_pings tate") so that the entry is something along the lines of =fnc_printer_pi ng([txt_ctrl_printe rip])
    Last edited by zmbd; Jun 26 '13, 06:42 PM. Reason: [z{clarified where the function should be placed}]

    Comment

    • Seth Schrock
      Recognized Expert Specialist
      • Dec 2010
      • 2965

      #3
      You would have to call your Ping function in the query that is the recordsource for the form. This would create another field that would give you your true/false result. However, this has the potential to take a long time to then open the form as it is having to ping each IP address. Just something to consider.

      Comment

      • RaffaEl13
        New Member
        • Jun 2013
        • 5

        #4
        Originally posted by Seth Schrock
        You would have to call your Ping function in the query that is the recordsource for the form. This would create another field that would give you your true/false result. However, this has the potential to take a long time to then open the form as it is having to ping each IP address. Just something to consider.
        Hi Schrock, thank you for your reply, I open the form from this:
        Code:
        DoCmd.OpenForm "PrinterReport", acNormal, , sWhere, acFormEdit
        sWhere contain the criteria of the request for exemple
        Code:
        sWhere = "building =" & Chr(34) & building & Chr(34)
        to filter all the printer in a specific building, (choosen with a combobox) anyway, my question is could I use this to call the "ping" function (named PrinterOnline) and how? Sorry I just build my code copying from different source but I begin in VBA and probably I ask question seeking in the false way. Thank you very much for your help!

        Comment

        • RaffaEl13
          New Member
          • Jun 2013
          • 5

          #5
          Originally posted by zmbd
          Fixed your title per your post.

          Your function should refer to the control on your form that has the IP address (say it's named "txt_ctrl_print erip") and be entered into the control source of the field (say it's named "txt_ctrl_pings tate") so that the entry is something along the lines of =fnc_printer_pi ng([txt_ctrl_printe rip])
          Hi zmbd, thank you for your reply, actually it works well on a form with one record, meaning one IP address, I call the function with this
          Dim strPrinter As String
          strPrinter = IP_Address.Valu e
          If Not PrinterOnline(s trPrinter) Then...

          (the function is called PrinterOnline).

          On the same form I have some combobox where I can select different criteria as the City or the Building where the printers are and through a button open a continuous form with the list of the printers resulting of the criteria choosen. On this continuous form I will ping each printer.

          But even with an easier table, for exemple a list of PCs inside a continuous form, I don't know how call my function as if I do it, I have only the first record line result duplicated on each following lines.

          Perhaps Schrock has given the solution but I don't yet understand how to implement it.

          Thank you very much for your help!

          Comment

          • Rabbit
            Recognized Expert MVP
            • Jan 2007
            • 12517

            #6
            You can not use an unbound control. You will need to use a bound control for this. Unbound controls can not have different values for different rows.

            Comment

            • Seth Schrock
              Recognized Expert Specialist
              • Dec 2010
              • 2965

              #7
              I'm going to assume your function is called PingFunction and that is has one argument that needs passed to it; the IP address. In that case, I will also assume that your query has a field named IP_Address. With all of these names, here is a sample of what the query would need to be.
              Code:
              SELECT PingFunction(IP_Address) AS PingResult, ...
              FROM ...
              WHERE ...
              This will make the query have a field called "PingResult " that will have the True/False result from your ping function for that record.

              Comment

              • zmbd
                Recognized Expert Moderator Expert
                • Mar 2012
                • 5501

                #8
                Rabbit You Confuzzzed me...
                Take a simple data calc.
                I have two bound fields, call them, "ctrl_tbldate_s tart" and "ctrl_tbldate_e nd"
                I want the time elapsed between these dates, so I have an unbound control, "ctrl_ub_calcda ys" wherein the control source I have =DateDiff("h",[ctrl_tbldate_St art],[ctrl_tbldate_en d])
                Default view is set for continous forms... this works here in that the elapsed time between the date/time is calculted for each record shown.

                So following behind that train... this should still work as I've suggested in #2, indeed, I have several forms that do just this very thing where the function sits in an unbound control and I feed information from the bound field to the function. (I should clear that up a tad in #2 too).
                Last edited by zmbd; Jun 26 '13, 06:43 PM.

                Comment

                • Rabbit
                  Recognized Expert MVP
                  • Jan 2007
                  • 12517

                  #9
                  Sorry @zmdb, you're right. I probably just used the wrong terminology. I was referring more specifically to my assumption from what the OP said. That assumption being that they are populating the value of the control through code rather than through the control source.

                  Comment

                  • RaffaEl13
                    New Member
                    • Jun 2013
                    • 5

                    #10
                    Originally posted by zmbd
                    Rabbit You Confuzzzed me...
                    Take a simple data calc.
                    I have two bound fields, call them, "ctrl_tbldate_s tart" and "ctrl_tbldate_e nd"
                    I want the time elapsed between these dates, so I have an unbound control, "ctrl_ub_calcda ys" wherein the control source I have =DateDiff("h",[ctrl_tbldate_St art],[ctrl_tbldate_en d])
                    Default view is set for continous forms... this works here in that the elapsed time between the date/time is calculted for each record shown.

                    So following behind that train... this should still work as I've suggested in #2, indeed, I have several forms that do just this very thing where the function sits in an unbound control and I feed information from the bound field to the function. (I should clear that up a tad in #2 too).
                    Thank you very much zmbd! It works fine. So simple (always simple when we know how)that I didn't think it could be done like that. Sorry for the time I did to answered, I only could tested it now. Best Regards!

                    Comment

                    • RaffaEl13
                      New Member
                      • Jun 2013
                      • 5

                      #11
                      Originally posted by Seth Schrock
                      I'm going to assume your function is called PingFunction and that is has one argument that needs passed to it; the IP address. In that case, I will also assume that your query has a field named IP_Address. With all of these names, here is a sample of what the query would need to be.
                      Code:
                      SELECT PingFunction(IP_Address) AS PingResult, ...
                      FROM ...
                      WHERE ...
                      This will make the query have a field called "PingResult " that will have the True/False result from your ping function for that record.
                      Thank you Seth for your help, I will try your solution also. As the one of zmbd works I began by the easiest one to implement. Best Regards!

                      Comment

                      Working...