Hey,
I have 2 append queries. The first is based off of code given and works great. For the second, I followed the format of the 1st and adjusted it to meet my needs. Query 1 works great. It appends each specific clientId to the table when the command button from form 1 is selected (code below). The 2nd query works as well. But it will only append 1 employee record to the table. I thought this must be because it is only allowing for 1 clientID to be appended, but when I switch to a different client and try to append an employee, it has the same response (not allowing it). If anyone has suggestions I would appreciate them. Thanks.
Background: 2 tables are being appended to. Table1 (tblAnswers), query1 (qryappendSelect), and form 1 all work perfectly. Table 2 (tblAnswersEmployee) follows the same format as tblAnswers, except it includes a EmlpoyeeId field. Qry2 and Form 2 were based off of the respective 1, qry2 had some code alterations to append the correct fields.
Query 1 - INSERT INTO tblAnswers ( ClientAutoID, QuestionNumber )
-
SELECT tblClient.ClientAutoID, tblQuestions.QuestionNumber
-
FROM tblClient, tblQuestions
-
WHERE (((tblClient.ClientAutoID)=[Forms]![frmClient]![ClientAutoID]) AND ((tblQuestions.QuestionNumber) Not Between 601 And 799));
Form 1 - Private Sub Update_Click()
-
On Error GoTo Err_Update_Click
-
Dim stDocName As String
-
stDocName = "qryAppendSelect"
-
If Nz(DLookup("[ClientAutoID]", "tblAnswers", "[ClientAutoID]=" & Me.ClientAutoID), 0) = 0 Then
-
DoCmd.OpenQuery stDocName, acNormal, acEdit
-
End If
-
Exit_Update_Click:
-
Exit Sub
-
Err_Update_Click:
-
MsgBox Err.Description
-
Resume Exit_Update_Click
-
End Sub
Query 2 - INSERT INTO tblAnswersEmployee ( ClientAutoID, EmployeeAutoID, QuestionNumber )
-
SELECT tblEmployee.ClientAutoID, tblEmployee.EmployeeAutoID, tblQuestions.QuestionNumber
-
FROM tblQuestions, tblEmployee
-
WHERE (((tblEmployee.EmployeeAutoID)=[Forms]![sbfEmployee1]![EmployeeAutoID]) AND ((tblQuestions.QuestionNumber) Between 601 And 605 Or (tblQuestions.QuestionNumber) Between 701 And 704));
Form 2 - Private Sub Update_Click()
-
On Error GoTo Err_Update_Click
-
Dim stDocName As String
-
stDocName = " qryEmployeeAppendSelect"
-
If Nz(DLookup("[EmployeeAutoID]", "tblAnswersEmployee", "[ EmployeeAutoID]=" & Me.EmployeeAutoID), 0) = 0 Then
-
DoCmd.OpenQuery stDocName, acNormal, acEdit
-
End If
-
Exit_Update_Click:
-
Exit Sub
-
Err_Update_Click:
-
MsgBox Err.Description
-
Resume Exit_Update_Click
-
End Sub
5 2047
Robert in Query 1 we were allowing for the fact that each client needed to correspond to all questions. The second query is different because each client won't correspond to all Employees.
As you have put ClientAutoID in tblEmployees that means each employee only has one client. This doesn't sound right - can you confirm?
Mary
Robert in Query 1 we were allowing for the fact that each client needed to correspond to all questions. The second query is different because each client won't correspond to all Employees.
As you have put ClientAutoID in tblEmployees that means each employee only has one client. This doesn't sound right - can you confirm?
Mary
Sorry for the confusion. The Employees discussed are the ones who work for the client. So each client (company) can have several employees. Each employee should only have 1 client (company).
I will try to look at my DB from an outside perspective when posting. I just take it for granted ya’ll all know what I’m thinking when I type which of course is not the case. So my bad. Thanks again.
Sorry for the delay in replying Robert. Can you post the structure of the tblEmployees and tblEmployeeAnswers tables for me to look at.
Mary
Sorry for the delay in replying Robert. Can you post the structure of the tblEmployees and tblEmployeeAnswers tables for me to look at.
Mary
Sure thing.
tblEmployee:
EmployeeAutoID (PK); ClientAutoID (FK) linked to tblClient 1 to many; the other fields are all general employee information (name….).
tblAnswersEmployee:
EmployeeAnswerAutoID (PK); EmployeeAutoID (FK) linked to tblEmployee 1 to many; ClientAutoID (FK) linked to tblClient 1 to many; QuestionNumber (FK) linked to tblQuestions 1 to many; EmployeeAnswer.
Robert,
Try this. I've moved some of the Brackets. Copy and paste it as is. Access may add some more don't worry about it. If this doesn't solve the problem email me the database after christmas and I'll have a look. -
INSERT INTO tblAnswersEmployee (ClientAutoID, EmployeeAutoID, QuestionNumber )
-
SELECT tblEmployee.ClientAutoID, tblEmployee.EmployeeAutoID, tblQuestions.QuestionNumber
-
FROM tblQuestions, tblEmployee
-
WHERE ((tblEmployee.EmployeeAutoID = [Forms]![sbfEmployee1]![EmployeeAutoID])
-
AND ((tblQuestions.QuestionNumber Between 601 And 605)
-
Or (tblQuestions.QuestionNumber Between 701 And 704)));
-
Merry Christmas
Mary
Sign in to post your reply or Sign up for a free account.
Similar topics
by: JMCN |
last post by:
hi
i have a general question regarding append queries in access 97. each
week i need to update my table(tblonlinereg) with new or modified
records. firstly, i import the text file into my...
|
by: karinski |
last post by:
Hi All,
I have a split f/e - b/e setup on my database with RWOP queries on the
front end. The code below gets a PO number(s), and vendor name from a
multi choice list box on another form. It...
|
by: aaronm49 |
last post by:
I have created an append query and I am having a problem with the
format of the number column when it appends. For example. 4.5 appends
as 4,a value of .5 appends as 0. I have adjusted the append...
|
by: David Barger |
last post by:
Greetings,
It appears that an Append Query I run in Access XP is randomly failing
to append a field.
I have payroll data being entered into a payroll database. This data
is exported daily to...
|
by: Lee |
last post by:
Hello All,
First of all I would like to say thank you for all of the help I have
received here. I have been teaching myself Access for about 4 years
now and I've always been able to find a...
|
by: Geoff |
last post by:
I am running an append query using query by example (but included equivalent
SQL code). The query counts the number of bookings and appends this number
to bookings to Tbl_Weekly
INSERT INTO...
|
by: James Hallam |
last post by:
I have a form with a subform. When there are no entries in the
subform, I have an append query which makes a default entry in the
subform (for what I am doing there needs to be at least one value...
|
by: DHarris |
last post by:
I created a continuous form in Access2003 based on a query that users review customers and once reviewed clicks on a command button that executes an append query to update a table of the reviewed...
|
by: jinalpatel |
last post by:
I have two tables. tblClass and tblWithdrawn. On my main form(bound to tblClass) I have several data entry fields like
Date withdrawn,
Status (active or withdrawn)
Date Classified etc.
Also...
|
by: iheartvba |
last post by:
Hi,
I have a simple append query which takes data from a form and appends it into a table.
INSERT INTO tblSmsSent ( MobileNumber, ClientName, TimeSent, AppointmentTime, AppointmentDate )...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
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...
|
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...
|
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,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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$) {
}
...
|
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...
|
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
|
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...
| |