Help Needed In Creating A Table Inside Db UsingVBA
Apr 27, 2005
Hi experts. i wrote this code that supposed to create table inside the access db but when i run it i
get this error:
compile error:
user -defined type not defined for Dim db as Database
Itt is a command button that calls CreateDatabase. I be happy if some one help me fix this. Thanks
My code:
Option Compare Database
Public Sub CreateDatabase()
' Routines to create the tables.
CreateTablePlayers
'CreateTablePenalties
' Routine to create relations for the tables.
CreateRefInt
End Sub
Private Sub CreateTablePlayers()
' Local variables
Dim db As Database
Dim tbl As TableDef
Dim fld As Field
Dim idx As Index
Set db = CurrentDb()
Set tbl = db.CreateTableDef("Players")
' Adding fields
Set fld = tbl.CreateField("playerno", dbInteger, 0)
fld.Required = True
tbl.Fields.Append fld
Set fld = tbl.CreateField("name", dbText, 25)
fld.Required = True
tbl.Fields.Append fld
' Add Table to the database
db.TableDefs.Append tbl
End Sub
' Adding Referential Integrity
Private Sub CreateRefInt()
' Local variables
Dim db As Database
Dim fld As Field
Dim rel As Relation
Set db = CurrentDb()
Set rel = db.CreateRelation("PlayersPenaltiesRel", "Players", "Penalties")
rel.Attributes = dbRelationUpdateCascade
Set fld = rel.CreateField("playerno")
fld.ForeignName = "playerno"
rel.Fields.Append fld
db.Relations.Append rel
End Sub
Private Sub Command1_click()
CreateDatabase
End Sub
creating a searching form and to show the results inside the form! It's like a Library type searching. u want to search for some type of monument or so and it shows the results, all the info, photos and that!
I need to have a form which has a series of blank text boxes on it.
I then need a subform, that has all of the text boxes as above, in datasheet layout.
I then want to be able to type values into the text boxes on the main form, and have the user then click a button. If any records exist with the values that have been typed in, they should be listed on the sub form.
If the main part of the form had combo boxes then that would also be good.
Finally, I want the user to be able to double click on one of the rows that have been found, and for this data to be loaded into a third form.
Is this possible? Could someone help me out, by maybe linking me to a source that will help me, by explaining how to do it, or maybe by letting me know where i can get a sample database that does this sort of thing.
i add a tab control, but i want to insert a table inside my tab how can i do that?..cant find any tables in my design tab when i work on my tab control
I've been testing my scripts so my database has a whole bunch of bogus records in it. I'd like to simply delete everything out of my orders table (there aren't any legit ones in there yet) so that I can start over when I go live and not have all that crap in there.
Is there an easy way to do this without re-creating a blank database and copying/pasting table only over?
I have a table with all my contacts. Manufacturers, distributers and outlet shops. I want to be able to make relationsships that show which manufacturers sell to which distributers and outlet shops, but at the same time I also want to be able to see which manufacturers are being sold by a particular outlet shop or distributer.
I am reading everywhere that you need to make a table to link the 2 tables together for every one relationship you have and this I understand. Most of the time it is relations between 2 tables that you want to establish. But in this case all these companies are in the same table. Can I still make a many-to-many relations ship between different items that are all in the same table using one single extra table that holds these relationships?
I'm having a problem with the syntax of a recordset of a Datasheet inside a subform which is also inside a Main Form.
Main Form - frm_1_0_LMS Subform - frm_1_4_0_TeamApprovals Subform(Datasheet) - frm_1_4_1_TeamApprovalsList
Here is my code:
Code:
Dim rs As DAO.Recordset Set rs = Forms!frm_1_0_LMS.frm_1_4_0_TeamApprovals.frm_1_4_1_TeamApprovalsList.Form.Recordset If Not (rs.EOF And rs.BOF) Then Forms!frm_1_4_2_ApproveDeclineUserLeave.Controls("lblFiledDateLeave").Caption = rs!Leave_Date End If
I am getting this error: Object doesn't support this property or method
I need urgent help, I am required at my job to come up with a command that will check to see if a table exists, and if so, delete the table. The whole process goes like this:
There's a form, and a listbox. 2 buttons...1 is import a file and 2nd is generate report. In the listbox theres 3 excel files. You select one excel file then click on Import, followed by clicking on Generate Report button.
The whole technical process is this: 1. A csv file is imported into a temp table 2. A temp table is created and named "_ImportedSKUS". 3. An append query is exectued to add the data from the "_ImportedSKUS" temp table to the final table, "Imported SKUs". 4. Then the temp table, "_ImportedSKUs" is closed and deleted.
I have a delete command at the end of the sub, which goes like this:
DoCmd.DeleteObject acTable, "_ImportedSKUS".
But I'm also need to generate an If statement before the loop that will check to see if the "_ImportedSKUs" table exists, if so, delete it (using same code listed above) and end if.
Hi Everyone, I need help in selection of primary key and designing of a tables. I am having a table called Current trailers with Trailer number as a primary key. I have similar table to current trailers called history table in which the trailers that left the yard are stored. As a trailer can enter and exit the yard couple of times in a week, its not letting me to have duplicates in the history table.So can anyone help in selection of primary key for the history table. Or can anyone tell me how I can have duplicates in a table.
I’m having trouble defining Relationships I’m thinking I need a “Junction” Table and I have tried looking at the Orders.mdb but it hasn’t helped (I’m sure I’m just missing something) I just don’t see how it works. If at all possible please don’t just give the info try to help me understand so I can get the answer myself. Here is what I have: Far table: FarNumID (PK) > autonumber FarNumber > Text “224-10C” FarTitle> Text
FarParagraph table: FarParaID (PK) > autonumber FarNumID > Number FarParaTitle > Text FarParaText > Text
AC table: ACNumID (PK) > autonumber ACNumber > Text ACTitle> Text
ACParagraph table: ACParaID (PK) > autonumber ACNumID > Number ACParaTitle > Text ACParaText > Text
1. Each FarNumber can have only 1 FarTitle 1:1 Each FarNumber can have many FarParaTitles 1:Many Each FarNumber can have many FarParaText 1:Many 2. Each FarTitle can have many FarParaTitle 1:Many Each FarTitle can have many FarParaText 1:Many 3. Each FarParaTitle and have only 1 FarparaText 1:1
I am looking to set up tables in such a way that will allow for the concept: If Variable 1=A and Variable 2=B then Output of 3=C
For Example: If the House is "Blue" And the Man drinks "Beer" Then his pet is a "Dog"
If the House is "Green" And the Man drinks "Vodka" Then his pet is a "Bird"
NOTE: There is no equational relationship between the first two variables to get the 3rd output. It is simply a lookup table. In excel you would have the color house down the left, the drink across the top and in the cells would be the type of pet. But I am struggling with how this can be made to function within Access since I will want the user to obviously be able to pick the first two variables and have the "answer" spit out.
I will give you an overview of what I have. I have a database that records sites in Blackburn and each site has a unique ID (RTP_ID). Each site has 10 objectives with 25 Measures in which the sites are scored against. Objective 1 has 2 measures Objective 2 has 8 measures Objective 3 has 1 measure Objective 4 has 1 measure Objective 5 has 1 measure Objective 6 has 3 measures Objective 7 has 2 measures Objective 8 has 1 measure Objective 9 has 2 measures Objective 10 has 3 measures
Each site has the same objectives and the same measures, but the scores for each are individual.
I don't know how to create the relationship between them so that each site can have 10 objectives and 25 measures (with scores) individually. At the moment, I have them connecting as SiteDetails.RTP_ID > Objectives.RTP_ID and Objectives.OBJ_ID > Measures.OBJ_ID but it doesn't work, it thinks that the scores apply to every site.
Please help me, I know that this may not make sense without seeing the database, but unfortunately it is too large to attach.
I have almost finished my current database but I was asked to create a log table/log file that would list changes made to every record. Now my current database don't allow duplicate records, so any advice pointing me into the right direction will be helpful. I have ran through the search area and found nothing that I can use. Can any one help me out in this specific problem. I picked up a few books and none of them give examples of such things. Thanking you all in advance...
Could someone please share their opinion with me on the following:
I have a database with a Table which stores People's details, e.g. ID, Name, Surname, ...., etc (e.g. tblPeople) .
Now I have people filling out a questionnaire, of which the results I want to save in an Access table. Each person will fill out this questionnaire only once. The number of fields I will need to accomodate the answers to questions asked, is around 120. For example, an answer to Question1 will appear in a field called Q1. I know that the limit for fields in a table are 255, and my total fields in tblPeople so far are about 20.
Should I keep Q1 and all other fields in the same table as tblPeople, or create another table to hold all answers and create a one-to-one relationship between tblPeople and tblQuestions&Answers ?
Can someone give me a tip, in particular if this will cause performance problems?
I am designing a database for my company that keeps track of new classes and new courses created. I have a form for each with the create a class form taking the course title from the courses table/created course from the create a course form.
Here's my dilemma. I want to use cascading combo boxes for class location, facility and room but I think my table structures and relationships may be incorrect.
Here is a list of my tables and their fields:
tblClass ClassID (PK) CourseID (FK) InstructorID (FK) StartDate EndDate StartTime EndTime ClassMin ClassMax Materials (yes/no) MatNotes EmpID (this is the ID of the employee who requested a class creation) LocID FacID RoomID LogID (Logistical Coordinator ID, if applicable)
Course CourseID (PK) CourseName more...
Employee EmpID (PK) FName LName more...
Instructor InstructorID (PK) FName LName more...
Logistical LogID (PK) FName LName more...
Locations LocID (PK) Location
Facilities FacID (PK) Facility LocID (FK)
Rooms RoomID (PK) Room FacID (FK) LocID (FK)
When I run a query with class, locations, facilities, and rooms no information shows up. If I run the query with the relationships between facility/room, facility/location and room/location removed (leaving the only relationships between class and these three) it works. Why is that? Shouldn't there be a 1-M relationship between Location, Facility and Room? Or, should there be a M-M relationship and I should create tables with each PK?
I apologize for the long post but this has become quite frustrating (despite the simple logistics).
I manage academic papers whom are written by multiple authors and reviewed by multiple reviewers. Currently, all the data is stored in one big table and I'm not able to get any statistics or real tracking out of it.
I have set up a test DB with 3 tables so far:
Main Table_ID -auto sequential key CORP_ID -internal paper id STATUS -open, overdue, accepted, rejected REC_DATE -received date MOD_DATE -record last modified date TITLE AUTH1_ID -linked to Author.ID AUTH2_ID -linked to Author.ID REVR1_ID -linked to Reviewer.ID REVR2_ID -linked to Reviewer.ID
Author ID -key field NAME DESIG -designation EMAIL PHONE
Reviewer ID -key field NAME DESIG EMAIL PHONE RATING
My goals are these:
Create a module that manages the authors. They are usually the same group of people. Each author should only appear once.
Create a module that manages the reviewers. Also, usually the same people (but different than authors). Each reviewer should only appear once.
Create a main form that allows the end user to add a record (paper), assign author(s), assign reviewer(s).
Create Query/Report that would then be able to: - track authors and their papers - track reviewers and their reviews - as well as track papers and their authors/reviewers
When I create subforms, they appear to be 'backwards' meaning that the Author form tends to be the main form and the Main form tends to be the subform. I think this is b/c the Author.ID field is the key field, whereas the Main.TABLE_ID is the key field, but not relevant for other than keeping things straight, nor is it related.
Can someone point me in the right direction?
Alternatively, has someone created a database like this already that I can buy? :)
Firstly, I want to admit that my knowledge about data base construction is fairly basic. I am trying to build a data base for humanitarian projects that do not at all resemple of the usual examples including customers, invoices, suppliers and what have you. My problem in constructing the DB is that most of the projects will address more than one subject and also include more than one target group and even operate in more than one country. In my first attempt I filled the relevant fields (subjects, target groups and country) with more than one value using a form with multi select lists. The problem was that it was very difficult to query these multi-value fields and kind people in this forum strongly advised my to reconstruct the DB avoiding such fields. What I need is to be able to view/print various selections based on precise criteria that include a region (or country), a subject and a target group in all kind of combinations. The problem is to decide on what tables to establish and their interrelation. I guess that when entering a project record (using a form) I will have to store somewhere what subjects (could be more than five) and target groups the project include. It is, of course, not a problem to establish special tables or value lists for the subjects and target groups and countries, but where/how do I store the basic project information for a project and the multi-values that are related to the individual project? I hope that this is not too confusing and I would appreciate any suggestion for a simple table structure and the interrelation between the tables. Many thanks in advance. Niels
Hi, based on previous advice I had merged my customers and owners into one table and selected whether a client was a customer, owner or both via a lookup table.
This is working fine, however I must assign a rep to each owner, I'm not quite sure how to do this, I need to be able to assign a rep to an owner in the clients table, I must also make sure than a rep can not be assigned to someone who is just a customer obviously.
I have attached the database (http://jonroberts.redirectme.net/database.zip), hopefully that will make things more clear.
I am designing a database to store volunteers and what particular function they are volunteering for. I have about 17 areas of volunteering tasks (i.e. Fundraising, Teacher) and at least 3 subcategories for those tasks (i.e. candy fundraisers, nursery school teacher). I want a form that you can enter the volunteer's info and then choose as many areas of interest and as many subcategories. I guess this would be done with checkboxes? Right now I am putting each volunteer task in seperate table (ie. Fundraising table, Teaching Table) and then trying to use combo boxes. But I want the person to be able to choose one or many activities.
Can anyone help me design this or give me a suggestion so that I can query or create a report to list the volunteer and what activities they want to volunteer for. I really appreciate any help I can get at this point. My email is ebbr820@hotmail.com or I will check back on this forum.
The Lookup table has two fields containing values that are needed: Description and Amount ($). In the table that uses the Lookup, I'd like to have both values shown, but have a dropdown just once. In other words, when the user selects a description (the dropdown shows both the description and amount), can the amount be inserted into an Amount field as the description is done currently.
Hi all, i need some help constructing a query that will create a table for me that does not include the Type value of 'promotion' if the same ID value exists elsewhere within the query.For instance, in the example below, i would want to delete the first entry containing 'Promotion' because ID2001 exists in two other places. However, if only one instance of ID2001 'Promotion' existed in my query, i would want to keep that entry. I would prefer to write all my data to a new table called "Test", This query has to sort out about 1000 entries when executed, otherwise i'd do it manually.I'm pulling my hair out with this one, so could someone help me?ID Company Name TypeID2001 Disc plc John PromotionID2001 Disc plc Paul AgentID2001 Disc plc George Agent
hi everybody, great resource you have here! my employer is tracking around 250 pieces of data for each client at our facility. i am making a new access system based on their existing mysql database and web front end. before i start messing around with forms and reports, i want to see how well this existing structure will work in access, and what kind of approach i should take. i am a newbie with access, but lots of experience with asp/mssql/php/mysql. making web forms is so time consuming that i figured i would be best off moving the whole thing to access and starting from scratch.
client information is stored in eight tables. each table has around 30 fields in it. the first table has a primary key autonumber, and the other seven tables have foreign keys with unique constraints that point back to the first table. that is, for each client record in the first table, there can only be exactly one corresponding record in the other tables.
i did some data massaging, and got the eight client tables into one big table, but the resultant table has almost 250 fields in it, and access doesn't seem to like working with tables that big. so i am thinking that it is best to leave the eight tables separate, but linked in one to one relationships.
i was kind of ideally visualizing a form with eight tabs so that i could edit/update all of the information from the eight tables rather seamlessly.
my question is: what approach to table structure will best suit my needs, and what approach should i take to add/update/delete the info with forms? will i need to do vb for this? any good one-to-one example databases anybody could point me at?
How do I create a table that can cross index items in another table. Maybe I am not using the right terms here so let me show a small example.
Say I have a tables of words. tblWords numWordID txtWord
Then I have some entries, all more or less synonyms of each others fresh new clean
Now I want to create a cross-index table, related to the table "tblWords" where I can select synonyms from words already in the table "tblWords", so if I for the word "fresh" add "new" and "clean" as synonyms or entries, if I then go and look at the word "new" it will already have the synonyms "fresh" and "clean", likewise the entry "clean" will then have the synonyms "fresh" and "new".
Kind of a many to many relationship junction table but only with one table!
I hope my explanation have not been to confusing, but let me know if you need a clarification.
Hi, I ve got an access db thats attached to a java application. I need to be able to create a temporary table that stores a result set, its necessary to do this as the java app needs to perform lots of repeated operations on this temp table.
I was think something like this would work:
DROP TABLE tempResults CREATE TABLE tempResults AS SELECT col1, col2, col3 .... FROM orginalTable
So i tried this:
Create table temptable AS SELECT education, FROM supermarketTable;
but it doesnt work, access complains about syntax error in create statment.