You have created a form with the table as the source, correct?
Check Box Help
Collapse
X
-
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):
You also need to set a reference (Tools->References) to the Microsoft DAO 3.6 Object LibraryCode: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
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
-
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
-
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.Originally posted by wlc04Rather 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.
Thanks for all your help, and your patience.Comment
-
Originally posted by wlc04Do 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
-
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
-
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.Originally posted by wlc04So 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.
Thanks,Comment
-
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
-
Ok this is where I am at right now.Originally posted by wlc04You 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.
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 FilesComment
-
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
-
Ok thanks, Wendy. I sent you an email from my gmail account.Originally posted by wlc04I'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
Comment