• Store input

    Author
    Topic
    #489212

    I have this code in a form on a database:-

    Code:
    InputBendCert:
        strMessage = InputBox(“Enter Angle Bend Cert if applicable”, “Angle Bend Cert”)
       If strMessage = “” Then
            intNewItem = MsgBox(“You have not entered a Angle Bend Cert. ” & Chr(13) & Chr(13) & _
                “Do you want to print the report without without Angle Bend Cert?”, vbYesNoCancel + vbQuestion + vbDefaultButton2, “No Procedure”)
          If intNewItem = vbCancel Then Cancel = True
          If intNewItem = vbNo Then GoTo InputBendCert
      Else
          Me![BENDLABEL].Caption = “ANGLE BEND CERT No:  ” & strMessage
          Me![RECHECKCERTLABEL].Caption = “RE-CHECK CERT No: ” & Forms!frmCofCNew![ReCheck No]
      End If

    This prints the Angle Bend Cert and Re-Check Cert No on a report when printed. It is triggered by the value of a control on the form.The only thing is, it isn’t saved. If we need to re-print the report, this information has to be input again. We do it this way, so we don’t have to change the layout of the form just for certain items. Is there a way of storing the input into a table?

    Viewing 2 reply threads
    Author
    Replies
    • #1392068

      Rob,

      As long as the table/query the form is based on has a field to store the value in it is just an assignment in the for the True branch of the InputBox check. You could actually have the InputBox assign directly to the appropriate field eliminating strMessage. HTH :cheers:

      May the Forces of good computing be with you!

      RG

      PowerShell & VBA Rule!
      Computer Specs

    • #1392072

      Sorry if I sound a bit dumb, but how do I assign it. It’s a while since I created this database, and then I had help from the kind people on this forum. I understand what’s happening in the code I posted, but apart from that, I’m lost. There isn’t a field at the moment, but I can’t see why there shouldn’t be. It’s just we don’t want to make the form to complicated.

    • #1392075

      Rob,

      I’m going to defer here to those on the forum who are more adept at Access. I’m not really good at writing AIR code, e.g. I don’t have a copy of your DB so I can’t test the stuff and I wouldn’t want to lead you down the wrong path. Rest assured it isn’t really complicated it’s just that I don’t do this every day any more and am a little rusty and then of course there is the age tingy. 😆 I’m sure one of our really expert Access people will jump in shortly with what will seem extremely simple. Of course it always is if you know what you’re doing! Take Care and Good Luck. :cheers:

      May the Forces of good computing be with you!

      RG

      PowerShell & VBA Rule!
      Computer Specs

      • #1392279

        Is the form bound to the table where the data being printed is sourced from? If so then the easiest is to add the field where you want to store your input value and then add to your code after the data has been input:
        me.txtAngleBendCert= strMessage

        Otherwise you can use an update query to add the data to the table.

        • #1393425

          Thanks both. I tried your method Cronk, and was getting errors, eventually I got the button to open a subform which is linked to the main table, so the user can enter the relevant data. This worked fine in Administration mode, but when I run the database from the start, and try to print the report, get the message that Microsoft Office Access has encountered a problem and needs to close. No actual reason for the error, so I don’t know what’s going on. As I said, it works fine in administor/edit mode. Also when it closes after the error, it leaves the .ldb file open. If I open the database again, and close it immediately, the .ldb file clears.

          • #1393441

            Thanks both. I tried your method Cronk, and was getting errors, eventually I got the button to open a subform which is linked to the main table, so the user can enter the relevant data.

            We need more info about your table structure in order to know whether you need a subform to enter the AngleBendCert and ReCheckCertNo data – if you are storing multiple records for some related entity that would make sense, but if there is only one, then a subform doesn’t really seem necessary. (Unfortunately some of the older posts from the pre-Windows Secrets days are either garbled or missing entirely.)

            This worked fine in Administration mode, but when I run the database from the start, and try to print the report, get the message that Microsoft Office Access has encountered a problem and needs to close. No actual reason for the error, so I don’t know what’s going on. As I said, it works fine in administor/edit mode. Also when it closes after the error, it leaves the .ldb file open. If I open the database again, and close it immediately, the .ldb file clears.

            That suggests that your database is corrupted or that your installation of Access is misbehaving. What version of Access are you using? Also do you have all of the latest Office service packs installed? And the behavior with the .ldb file is normal when Access crashes. That is the lock file which permits multiple users to work on a single database at the same time. By design, Access checks to see if there are any other users connected to a database when it exits normally. If there are none, then the .ldb file is deleted.

            • #1394471

              Thanks WendellB, but I got it sorted. Probably the long way round, but I ended up creating a sub-form linked to the main table as the main form. That seemed to work. The database that wasn’t working, was a copy anyway, so nothing was lost. Thanks again both.

    Viewing 2 reply threads
    Reply To: Store input

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: