Check Box Help

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • wlc04
    New Member
    • May 2006
    • 70

    #16
    You have created a form with the table as the source, correct?

    Comment

    • cweiss
      New Member
      • Apr 2006
      • 36

      #17
      This is the code snippet from before, slightly modified and heavily commented (might be easier to read this if you paste it into a module):

      Code:
      Sub AddRecord()
      
      'Dimension your variables, db is of type DAO.Database
      'rs is of type DAO.Recordset
      Dim db as DAO.Database
      Dim rs as DAO.Recordset
      
      'Set the db variable to the database you are currently
      'working in, and set the rs variable to the table
      'you want to work with, in this case, the table's name
      'is TransactionErrors
      Set db = CurrentDb()
      Set rs = db.OpenRecordset("TransactionErrors")
      
      'The With statement is basically saying
      'I want to reference this variable, instead
      'of typing out rs.Add, while inside the
      'with block you can reference it by saying
      ' .Add
      With rs
        'You must tell the recordset you want to add a record
        'if you wanted to modify a record you would type
        ' .Edit instead
        .Add
      
        'The value of the field "MainTablePrimaryKey" should be
        'set to the value contained in the Textbox txtVisitID
        .Fields("MainTablePrimaryKey") = txtVisitID 
      
        'The value of the field "ErrorID" should be set to the
        'value contained in the checkbox chkError's DefaultValue
        'property
        .Field("ErrorID") = [B]chkError1.DefaultValue[/B]
      
        'Update the recordset with the data you just added
        .Update
      End With
      
      End Sub
      You also need to set a reference (Tools->References) to the Microsoft DAO 3.6 Object Library

      This is how you would go about adding the record to the table, if you have no experience with VBA though, this might not be the best solution to start out with...

      Comment

      • wlc04
        New Member
        • May 2006
        • 70

        #18
        Rather than using the VBA - you could just set the source through the properties - MUCH EASIER.

        Let me start with this - Have you ever designed a form?

        Once I know this I will know how much detail to go into to help you.

        Comment

        • Mickster
          New Member
          • May 2006
          • 27

          #19
          Originally posted by wlc04
          You have created a form with the table as the source, correct?
          Yes, i did that.

          Comment

          • wlc04
            New Member
            • May 2006
            • 70

            #20
            Do you have the fields on the form yet? If so, right click and look at the properties - each textbox/checkbox... will show you which field it is referencing. Once they are on there and referenced to the correct field you should be set. This will work if you are using one table.

            Did you decide to use more than one table? If so, you'll want a query to join the data in the two and then use that query as the source for your form.

            Comment

            • Mickster
              New Member
              • May 2006
              • 27

              #21
              Originally posted by wlc04
              Rather than using the VBA - you could just set the source through the properties - MUCH EASIER.

              Let me start with this - Have you ever designed a form?

              Once I know this I will know how much detail to go into to help you.
              No, this is my first time. What I have read on the net is that Check boxes can only hold yes/no values. How can I change this so that it represents a value such as (1,2,3 ....) which will correspond to a medication error on a table.

              Thanks for all your help, and your patience.

              Comment

              • wlc04
                New Member
                • May 2006
                • 70

                #22
                You can't change the value of the checkbox. You'll have to adjust your thinking.

                I wish I could get the .mdb file I created to you - I think seeing it would be better for you, but we'll work around that.

                Comment

                • Mickster
                  New Member
                  • May 2006
                  • 27

                  #23
                  Originally posted by wlc04
                  Do you have the fields on the form yet? If so, right click and look at the properties - each textbox/checkbox... will show you which field it is referencing. Once they are on there and referenced to the correct field you should be set. This will work if you are using one table.

                  Did you decide to use more than one table? If so, you'll want a query to join the data in the two and then use that query as the source for your form.

                  Yes, ok i'm getting on track. I am using multiple tables so I have the form referencing the query. However, what I"m confused about is that since the check box represents a number in a field. How can I match each check box to a specific number in that field??...If that makes any sense.

                  Comment

                  • wlc04
                    New Member
                    • May 2006
                    • 70

                    #24
                    So you created a checkbox for each available error, correct?

                    Basically, you'll just reference each checkbox with an error by using the name of the error - don't think of them with values (1,2,3). You have a checkbox on the form which has it's source as Error1 from your query - when checkbox is ticked off then that value will update your table. Make sense? To be able to recognize which error is which on your form - just change the caption on it's corresponding label.

                    Comment

                    • Mickster
                      New Member
                      • May 2006
                      • 27

                      #25
                      Originally posted by wlc04
                      So you created a checkbox for each available error, correct?

                      Basically, you'll just reference each checkbox with an error by using the name of the error - don't think of them with values (1,2,3). You have a checkbox on the form which has it's source as Error1 from your query - when checkbox is ticked off then that value will update your table. Make sense? To be able to recognize which error is which on your form - just change the caption on it's corresponding label.
                      Ok things are looking a lot more clearer. However, where would I would I store the name of the error in the Checkbox properties, so that value can be referenced on the table.

                      Thanks,

                      Comment

                      • wlc04
                        New Member
                        • May 2006
                        • 70

                        #26
                        You might want to name the fields in the table so they can be recognizable.

                        On the form itself you can set the name property to anything you want. CkErr1 or CkWrgMed. Then if you create anything in VBA you will recognize it 1) it's a checkbox - because of the CK prefix and 2) which error it's referencing, either by number or desc.

                        If you do change the names, make sure you don't change the control source - this is how it updates your table.

                        Comment

                        • Mickster
                          New Member
                          • May 2006
                          • 27

                          #27
                          Originally posted by wlc04
                          You might want to name the fields in the table so they can be recognizable.

                          On the form itself you can set the name property to anything you want. CkErr1 or CkWrgMed. Then if you create anything in VBA you will recognize it 1) it's a checkbox - because of the CK prefix and 2) which error it's referencing, either by number or desc.

                          If you do change the names, make sure you don't change the control source - this is how it updates your table.
                          Ok this is where I am at right now.

                          I've created a mini DB that reflects what I am doing. So if you dont mind looking at it giving me some suggestions on whether I am on the right track or not it woudl be much appreciated.
                          Attached Files

                          Comment

                          • wlc04
                            New Member
                            • May 2006
                            • 70

                            #28
                            I'm having the same problem you had opening the zip file. Tells me there are no files in the archive. If you like, you can email it to me, but you'll have to change the extension because Outlook won't let an mdb file through. wlc04@tampabay. rr.com.

                            Comment

                            • Mickster
                              New Member
                              • May 2006
                              • 27

                              #29
                              Originally posted by wlc04
                              I'm having the same problem you had opening the zip file. Tells me there are no files in the archive. If you like, you can email it to me, but you'll have to change the extension because Outlook won't let an mdb file through. wlc04@tampabay. rr.com.
                              Ok thanks, Wendy. I sent you an email from my gmail account.

                              Comment

                              • Mickster
                                New Member
                                • May 2006
                                • 27

                                #30
                                Originally posted by Mickster
                                Ok thanks, Wendy. I sent you an email from my gmail account.
                                Hi Wendy,

                                I got a reply back saying that email address was invalid. Could you please confirm your email again please.

                                Thanks

                                Comment

                                Working...