473,379 Members | 1,174 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

Adding multiple records into my access-2003 tables

I would like to add records with preset data, if it is possible.
my tables with data as an example:
Name:Perodin, Sid: 05515, date:110425, effDate:110416, SO#:444-11, LikeOff:5, Reason:5th violation of smoking policy, Discp: $10fine, 5 hours study hall.

I would like to be able to put in a macro or form so that i input the SID# and offense number (and other data that changes), it auto pulls the name, adds today's date, and auto adds the x# violation and x# Discipline.

So if i entered 05515 and then 6, it would add the record like so:
Name:Perodin, Sid: 05515, date:110425, effDate:110416, SO#:444-11, LikeOff:6, Reason:6th violation of smoking policy, Discp: $10fine, 6 hours study hall.


what i am after is the ability to enter an offense type, then the student id and have it fill in where the info is the same.

example: for a smoking offense i would pull up smoking, be it a form or vba, enter the student id and other specific data, and have the for or vba fill in the rest. the "rest" that i am refering to is stuff like the offence type, the discipline and the codes we use to separate data.
Apr 25 '11 #1

✓ answered by NeoPa

Let me see if I can be clearer too. I see no reason why the comments that are repeated cannot be held in a separate table with an ID for each comment and the user can be allowed to select from this table in a ComboBox such that only the ID is stored in the updated record, but the reason is always shown.

6 2374
ADezii
8,834 Expert 8TB
I strongly suggest that you read up on Database Normalization via the following Link,
http://bytes.com/topic/access/insigh...ble-structures
but if you insist on following this course of action, the following Code will point you in the right direction:
Expand|Select|Wrap|Line Numbers
  1. Dim strName As String
  2. Dim strDate As String
  3. Dim strEffDate As String
  4. Dim strSONum As String
  5. Dim MyDB As DAO.Database
  6. Dim rst As DAO.Recordset
  7.  
  8. Set MyDB = CurrentDb
  9. Set rst = MyDB.OpenRecordset("tblDemo", dbOpenDynaset, dbAppendOnly)
  10.  
  11. 'At a bare minimum, need a Sid and Offense Number
  12. If IsNull(Me![Sid]) Or IsNull(Me![LikeOff]) Then Exit Sub
  13.  
  14. If DCount("*", "tblDemo", "[Sid] = " & Me![Sid]) = 0 Then
  15.   MsgBox "A SID of " & Me![Sid] & " does not exist in the Database!", vbExclamation, "No SID"
  16.     Exit Sub
  17. End If
  18.  
  19. strName = DLookup("[Name]", "tblDemo", "[Sid] = " & Me![Sid])
  20. strDate = DLookup("[Date]", "tblDemo", "[Sid] = " & Me![Sid])
  21. strEffDate = DLookup("[EffDate]", "tblDemo", "[Sid] = " & Me![Sid])
  22. strSONum = DLookup("[SO#]", "tblDemo", "[Sid] = " & Me![Sid])
  23.  
  24. With rst
  25.   .AddNew
  26.     ![Name] = strName
  27.     ![Sid] = Me![Sid]
  28.     ![Date] = strDate
  29.     ![EffDate] = strEffDate
  30.     ![SO#] = strSONum
  31.     ![LikeOff] = Me![LikeOff]
  32.     'Let's avoid the whole Suffix issue
  33.     ![Reason] = "Violation #" & CStr(Me![LikeOff]) & " of smoking policy"
  34.     ![Discp] = "10$ fine, " & CStr(Me![LikeOff]) & " hours study hall"
  35.   .Update
  36. End With
  37.  
  38. rst.Close
  39. Set rst = Nothing
Apr 25 '11 #2
NeoPa
32,556 Expert Mod 16PB
I would just strongly suggest you design the database so that it's normalised (see link in previous post) and ensure that associated information is stored in an appropriate place and not repeated in an inappropriate one.

Default values are another matter (I don't think that's what you're describing here) and there is a .DefaultValue property to most controls to handle this where appropriate.
Apr 26 '11 #3
i apologize if i am unclear, this is my first time trying to improve our data entry. our data base is over 10years old and i am limited in the changes i may or may-not make.

I would put in the SID, the offense#, the date of offense (so named in the table), the SO# is also entered by us, as it is the paper tracking number.
The stuff i want to automate is when i enter an offense, i need a standard statement entered into the table, so if a smoking violation, the reason field would have "# violation of tobacco violations", if was a cell phone violation, the reason would read "# violation of Cell Phone policy". there would be similar entry's for discipline. i am taking over a system that has been in place, and it requires you type everything in. i do not feel the repeat data needs to be typed. the tables report out to very specific and limited style.

for info, there are 2 databases, the first is student info. the second contains the records of all student offenses and awards. i can make some changes, i have put a relationship between the two so that while in the student DB, you can open 1 student and add his award/offense. if in the Off./award DB, you must enter all the student info into each record. this is very redundant and in my opinion, pointless, but i am forced to keep it.

I hope this clarifies the question and my situation.
Apr 26 '11 #4
NeoPa
32,556 Expert Mod 16PB
Let me see if I can be clearer too. I see no reason why the comments that are repeated cannot be held in a separate table with an ID for each comment and the user can be allowed to select from this table in a ComboBox such that only the ID is stored in the updated record, but the reason is always shown.
Apr 27 '11 #5
Thanks to you all for you help and time .
Apr 28 '11 #6
NeoPa
32,556 Expert Mod 16PB
I hope that helped James :-)
Apr 28 '11 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

10
by: shank | last post by:
I have a recordset that contains multiple records of product a user is purchasing. For clarity, I converted the recordset fields to variables. I need to take that entire recordset and insert it...
5
by: crispy | last post by:
On this page, you'll see that some PubID's are repeated several times: http://www.ihea.info/pages/website/test1.asp That's because some records have more than one attribute. For example, Title...
1
by: mellie | last post by:
Hi there, SQL 2000 database with ASP I've found many things "out there" regarding updating and deleting multiple records with checkboxes but I can't seem to find anything about adding them. ...
2
by: JMCN | last post by:
i am running into problems with is the recordset. i have exactly 104 records. when i tested the code, the end result was multiple records for the same loan(ET LN Shortname). where did i go wrong? ...
6
by: Wendy Powley | last post by:
I have a subform which represents a 1:N relationship with the main form. I would like to be able to read values from an external file, fill the subform with the values read & allow the user to...
5
by: Kaur | last post by:
Hi, I have been successful copying a vba code from one of your posts on how to copy and paste a record by declaring the desired fields that needs to be copied in form's declaration and creating two...
3
by: sgtsaltandpepper | last post by:
Hi, i am making a database to track the training courses that employees have to attend for my brothers company. There is one main table involved in what i am trying to do it is called...
4
4Him
by: 4Him | last post by:
First off, let me say this is a great site! I've just started working with Access and much of my success is from what I've read here! Background: I have a form, driven off a single table. Goal:...
1
Stephen74
by: Stephen74 | last post by:
I am trying to add multiple records to a single table using a SQL without using a loop in VBA. Is this possible? sample table tblNames FName | LName | Company...
0
by: tomric | last post by:
I have a table set up that is used for viscosity data on a our parts. There are are eight different checks over three different materials that go into construction of our parts. There can also be...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.