Results 1 to 8 of 8

Thread: Store input

  1. #1
    5 Star Lounger
    Join Date
    May 2003
    Location
    Sheffield, Yorkshire
    Posts
    951
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Store input

    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?

  2. #2
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    9,434
    Thanks
    371
    Thanked 1,457 Times in 1,326 Posts
    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
    May the Forces of good computing be with you!

    RG

    PowerShell & VBA Rule!

    My Systems: Desktop Specs
    Laptop Specs

  3. #3
    5 Star Lounger
    Join Date
    May 2003
    Location
    Sheffield, Yorkshire
    Posts
    951
    Thanks
    1
    Thanked 0 Times in 0 Posts
    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.

  4. #4
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    9,434
    Thanks
    371
    Thanked 1,457 Times in 1,326 Posts
    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.
    May the Forces of good computing be with you!

    RG

    PowerShell & VBA Rule!

    My Systems: Desktop Specs
    Laptop Specs

  5. #5
    Lounger
    Join Date
    Feb 2011
    Posts
    43
    Thanks
    0
    Thanked 6 Times in 6 Posts
    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.

  6. #6
    5 Star Lounger
    Join Date
    May 2003
    Location
    Sheffield, Yorkshire
    Posts
    951
    Thanks
    1
    Thanked 0 Times in 0 Posts
    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.
    Last edited by robm; 2013-05-23 at 08:33.

  7. #7
    Super Moderator
    Join Date
    Aug 2001
    Location
    Evergreen, CO, USA
    Posts
    6,623
    Thanks
    3
    Thanked 60 Times in 60 Posts
    Quote Originally Posted by robm View Post
    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.
    Wendell

  8. #8
    5 Star Lounger
    Join Date
    May 2003
    Location
    Sheffield, Yorkshire
    Posts
    951
    Thanks
    1
    Thanked 0 Times in 0 Posts
    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.

Posting Permissions

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