473,396 Members | 1,713 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,396 software developers and data experts.

Multiple table entries upon single selection

52
Is there a way to have Access enter multiple entries to a database based on a form where the user has selected a certain criteria? I am hoping to have my form enter multiple entries within a table but each entry will have different information.

What I have is an event log which tracks all the versions of software which is being installed within our servers. I have four servers which “should” mimic each other therefore, when an application is installed or updated on one, the others also get updated (with a different sever name of course). Therefore when I enter an event (within my form) I would like it to actually enter four events within my database for each server.

I believe I need to add code to the “On Click” control but from there I have no clue on how to proceed. I am thinking that a case statement may be needed, am I way off base here?

Any help would be greatly appreciated.

Thanks,
Birky
Feb 1 '07 #1
7 2076
Rabbit
12,516 Expert Mod 8TB
For clarification.

Is it something like a table with 2 fields.

Tbl_Apps
ServerName Application

And you have 4 servers: Server1, Server2, Server3, Server4.

When you add one application to a server, you want 4 entries.

Server1 App1
Server2 App1
Server3 App1
Server4 App1
Feb 1 '07 #2
NeoPa
32,556 Expert Mod 16PB
Birky, please do reply to Rabbit's reasonable question.
But in a general reply to a general question, you could add some code that runs an INSERT INTO (Append) query for records from a table containing all the four servers and your software ID from the form being addedd into another table (where you want it) using a WHERE clause that selects (using In()) just those records that match the servers you're interested in.
To fill out the flesh we need MetaData of all relevant tables (and an answer confirming Rabbit's supposition).
Feb 1 '07 #3
Birky
52
Sorry about that, I should have provided more info. To answer Rabbit’s question the answer is yes, exactly. The form I have is tied to only one table (called Event_Log). This table only has a few fields in an attempt to keep it simple.

Event_ID (auto generated number which serves as the primary key)
Application_Name
Version
Date_Installed
Date_Recorded (auto populated without any user intervention)
Comments

The form basically has all these fields contained within. I have four servers name TEST1, TEST2, TEST3, and TEST4. So in an effort to save time and keystrokes, if were to add an entry for any one of these server I actually need an entry within the Event_Log for each Server with the added application or updated version.

To throw a monkey wrench into the mix; I also have other Servers within the database that do not fall within this scenario and should be tracked individually. This is why I was thinking of a case statement… Am I way off base here? Please correct me if I’m wrong but is not a case statement basically a where clause within VBA? I may be barking up the wrong tree for I am learning that there are easier ways to skin a cat (key word here is learning).

I do appreciate your help on this one..
Birky
Feb 2 '07 #4
NeoPa
32,556 Expert Mod 16PB
Birky, I think you misunderstand me. There is no cause to apologise as you'd not done anything at that point. I was merely trying to ensure you didn't miss Rabbit's post simply because I'd posted after it ;)
I'll leave you with an idea for the moment. Let me know if you manage to run with it and if not I'll fill in some more details later.
Think of a Server table (tblServer) which contains a record for each server. It also has a field to indicate whether or not a server should be auto-populated with your data.
Expand|Select|Wrap|Line Numbers
  1. Table Name=tblServer
  2. ServerName; Text; PK
  3. PopFlag; Boolean (Yes/No)
If you link this in with the idea I laid out in post #3, you should have a workable solution.
Feb 2 '07 #5
Birky
52
NeoPa , I’m truly lost here. Not sure if it is due to me being a novice or if I just can’t get my brain cell around this one. I am truly willing to learn if you’re willing to teach me. If you could break this down for me so I can grasp it I would be extremely grateful.

I have purchased several books in hopes of learning Access and VBA but none of them cover this type of scenario. Your help is much appreciated!

Thanks for taking the time…
Birky
Feb 3 '07 #6
MMcCarthy
14,534 Expert Mod 8TB
Birky,

My suggestion would be to use a multiselect listbox of servers. Then for each selection in the list a new record could be added with the other data from the form.

Example:

Event_Log table has a field to hold server name also

On the form:
lstServer (Name of a multi select listbox) - Lists all available servers
cboApplication (Name of combobox with list of possible applications)
Version (datatype number assumed)
Date_Installed
Comments
cmdAddEvents (Command button on the form)

Code behind command button cmdAddEvents:
Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdAddEvents_Click()
  2. Dim valSelect As Variant
  3. Dim strValue As String ' to hold the values for the update
  4.  
  5.    For Each valSelect In Me.listboxName.ItemsSelected
  6.       strValue = "'" & Me.lstServer.ItemData(valSelect) & "', '" & Me.cboApplication & "', " & Me.Version & ", #" & Me.Date_Installed & "#, #" & Date() & "#, '" & Me.Comments & "'"
  7.       DoCmd.RunSQL "INSERT INTO Event_Log (ServerName, Application_Name, Version, Date_Installed,  Date_Recorded, Comments) VALUES (" & strValue & ");"
  8.    Next valSelect
  9.  
  10. End Sub
  11.  
Feb 4 '07 #7
NeoPa
32,556 Expert Mod 16PB
NeoPa , I’m truly lost here. Not sure if it is due to me being a novice or if I just can’t get my brain cell around this one. I am truly willing to learn if you’re willing to teach me. If you could break this down for me so I can grasp it I would be extremely grateful.

I have purchased several books in hopes of learning Access and VBA but none of them cover this type of scenario. Your help is much appreciated!

Thanks for taking the time…
Birky
This is not as easy as I'd anticipated with a quick look earlier. It is possible, with a subquery built up from data on your form. We'll use these three fields (Assuming the form controls have the same names listed here.) :
Expand|Select|Wrap|Line Numbers
  1. Application_Name; Text
  2. Version; Numeric
  3. Date_Installed; Date
as illustrations. First of all we need to understand the concept of a SQL SELECT query with just literal values (See Literal DateTimes and Their Delimiters (#).). This will have no FROM clause at all! Also, we need to build this SQL string up in VBA code.
Expand|Select|Wrap|Line Numbers
  1. Dim strSQL As String
  2.  
  3. strSQL = "SELECT '" & Me!Application_Name & "' AS Application_Name," & _
  4.          Me!Version & " AS [Version]," & _
  5.          Format(Me!Date_Installed,'\#m/d/yyyy\#') & " AS Date_Installed"
We will now use this query as a subquery datasource in our INSERT INTO (Append) query. This will use an OUTER JOIN (otherwise known as unjoined) to the tblServer table from post #5.
Expand|Select|Wrap|Line Numbers
  1. strSQL = "INSERT INTO [Event_Log] " & _
  2.          "(Application_Name,[Version],Date_Installed) " & _
  3.          "SELECT subQ.* " & _
  4.          "FROM (" & strSQL & ") AS subQ,tblServer "
  5.          "WHERE tblServer.PopFlag"
With tblServer data of :
Expand|Select|Wrap|Line Numbers
  1. TEST1; Yes
  2. TEST2; Yes
  3. TEST3; Yes
  4. TEST4; Yes
  5. TEST5; No
  6. TEST6; No
  7. TEST7; No
  8. TEST8; No
you would get entries added for TEST1; TEST2; TEST3 & TEST4 only. Adding another auto=populating server would be a simple matter of adding a record as Yes for a new server or changing an existing server to Yes from No.
Feb 4 '07 #8

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

Similar topics

2
by: Joe | last post by:
Hey, I'm going to give some background on my situation in case anyone can point out a way around my problem altogether... for the problem itself, please skip to the bottom of the post. thanks....
3
by: svdh2 | last post by:
I have been looking at a problem the entire week in access, I have still not been able to find a solution. Hope that you could maybe tell where to look Concerns the link between Access and Word....
6
by: Ralph2 | last post by:
Some time ago with a lot of help from this group I made a reasonably successful database to keep track of our shop drawings. However the searching mechanism is too complicated for the occasional...
2
by: .Net Newbie | last post by:
Hello, I am currently coding my ASP.Net pages in c# and have run into a question concerning Emails. I have four objects on a page (six including 2 buttons). The first is a subject line...
9
by: Gummy | last post by:
Hello, I created a user control that has a ListBox and a RadioButtonList (and other stuff). The idea is that I put the user control on the ASPX page multiple times and each user control will...
13
by: franzey | last post by:
This is how the data is organized: vID Answer 12 Satisfied 12 Marketing 12 Yes 15 Dissatisfied 15 Technology 15 No
5
by: rameshbhojan | last post by:
Hi All, Please let me know if there is way in which i we can make multiple selections from a drop down list. The requirement is as follows: I have a drop down list, whose entries are to be...
2
by: Iain Wilson | last post by:
Hi Can anyone please advise if this is possible and if so how I would go about it (a pointer to an example would be greatly appreciated). Using C# - Web Application I have a DropDownList with...
482
by: bonneylake | last post by:
Hey Everyone, Well i am not sure if this is more of a coldfusion problem or a javscript problem. So if i asked my question in the wrong section let me know an all move it to the correct place. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.