I have a table for employees and a table that shows which containers they have access to and a table of all containers.
What i need to do is when adding a new employee i need to add a record to the "access" table for each record in the container table. that would basically default the new employee's access to each container.
I think the following code in my addemployee form_Load event should detect if they have been added. but i'm having trouble with figureing out how to proceed on what needs to done. - Dim emp As String
-
emp = "employee = " & Staffadd.ID
-
If DLookup("[Containerstring]", "access", emp) = Null Then
the above code should only detect a null if there is not an entry for the employee in the "access" table
what i need help with is:
A) I don't know how to tell how many entreis are in the containers table.
and
B) I don't know how to programitacly add records to a table.
With this information i should be able to simply loop through the containers table and add a record to the access table for the new employee each record in the containers table.
2 1407
Time to use your friends (yahoo, google, ask, answers, bing) and search for vb6 ado tutorial. Then once you have absorbed that you can use these for your various questions. -
strSQL = "INSERT INTO tblEmp(vFName, vLName, iNumericField, dDateField) VALUES('" & Text1.Text & "','" & Text2.Text & "'," & Text3.Text & ",#" & Text4.Text & "#)"
-
-
?strSQL
-
INSERT INTO tblEmp(vFName, vLName, iNumericField, dDateField) VALUES('John','Doe',3,#6/10/2010#)
-
-
'Note: the date field surrounded by the pound sign (#) is an access thing while SQL Server will not accept a
-
'date surrounded by the pound sign but will accept a date surround by single ticks (') like the two varchar
-
'fields shown above ('John','Doe',...)
-
-
adoCn00.Execute strSQL
-
-
strSQL = "SELECT iEmpID FROM tblEMP WHERE vFName = '" & Text1.Text & "' AND vLName = '" & Text2.Text & "'"
-
-
adoRs00.Open strSQL, adoCn00,...
-
-
strSQL = "SELECT iConID, vConDesc FROM tblCon"
-
-
adoRs01.Open strSQL, adoCn00,...
-
-
Do While adoRs01.EOF = False
-
If adoRs01.Fields("vConDesc").Value = "Low" Then
-
strSQL = "INSERT INTO tblEmpConAccess(iEmpID, iConID, iAccessLevel) VALUES(" & adoRs00.Fields("iEmpID").Value & "," & adoRs01.Fields("iConID").Value & ",1)"
-
Else
-
strSQL = "INSERT INTO tblEmpConAccess(iEmpID, iConID, iAccessLevel) VALUES(" & adoRs00.Fields("iEmpID").Value & "," & adoRs01.Fields("iConID").Value & ",0)"
-
End If
-
adoCn00.Execute strSQL
-
adoRs01.MoveNext
-
Loop
-
-
strSQL = SELECT COUNT(iEmpConAccessID) As AccCnt FROM tblEmpConAccess WHERE iEmpID = " adoRs00.Fields("iEmpID").Value
-
-
adoRs00.Close
-
adoRs01.Close
-
Set adoRs00 = New ADODB.Recordset
-
Set adoRs01 = New ADODB.Recordset
-
-
adoRs00.Open strSQL, adoCn00,...
-
-
strSQL = SELECT COUNT(iConID) As ConCnt FROM tblCon
-
adoRs01.Open strSQL, adoCn00,...
-
-
If adoRs00.Fields("AccCnt").Value <> adoRs01.Fields("ConCnt").Value Then
-
'problem as employee was not added to each container
-
'so need to correct somehow
-
End If
-
-
adoRs00.Close
-
adoRs01.Close
-
Set adoRs00 = Nothing
-
Set adoRs01 = Nothing
-
or something like that...
Good Luck
Thanks for the Information, but apparently i posted in the incorrect area. I need information on VBA not VB6
Thanks again.
Wanders off to ask Google.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Kenneth Osenbroch |
last post by:
Hi. I want to create a trigger that only allows delete from table A if
corresponding record in table B does not exist. Any idea on how this
can be done? Thanks, Kenneth.
|
by: Michael |
last post by:
I have two tables with a 1-many relationship. I want to write a
select statement that looks in the table w/many records and compares
it to the records in the primary table to see if there are any records
that do not match based on a certain field.
Here is how my tables are setup:
Task Code Table
TCode,TCodeFName,Active
|
by: Bryan Zash |
last post by:
When querying a bit field, I am encountering a problem with MS SQL
Server returning a larger number of records for a table than the
actual number of records that exist within that table.
For example, my customer table has 1 million unique records, so the
results of the following query are as such:
select count(customer_nbr) from customer = 1,000,000
There is bit field in the customer table that denotes whether a
|
by: Gandalf186 |
last post by:
Good morning people,
I wish to use VBA to open an Access Query, loop through each record, and then based on the result of a certain field create calculations in which i wish to place as a new record in a new table.
If anyone out there can give be the basic code that will : -
Collect the Data,
Loop through data
create a new table
post variable to the new table (as records).
|
by: Forest14 |
last post by:
Hello! Happy Christmas/holidays to you all
I have this huge table named "Positions" with more than 160 fields of which the fields are named with non obvious abbreviations.
I have another table named "definitions" which has the column name and definition fields.
In order to help me all along my forthcoming developments, I would like to use these definitions from table "definitions" into "Positions". Of course i can manually copy each...
| |
by: underground |
last post by:
I wonder if possible on page load to query the value of a specific colmn and insert the result into another table. My query looks like so
<?
include("include/session.php");
?>
<?
$usr = "xxxx";
$pwd = "xxxxx";
$db = "xxxxx";
|
by: lunas |
last post by:
hi
i have to update a table based on a criteria with value selected from another table. i am writting a java progg for it . i just want to know can it be done with one statement.
my purpose is
result set rs =select (ID) from Tab1 where colmB is null
LOOP rs
select ID2 from tab2 where colC=ID
|
by: dstorms |
last post by:
Hi folks,
I am trying to set up my database to create a new record in one table when a new record is created in another. Since it is a one-to-one realtionship it certainly would be easier to put the data into one table. Originally it was one table, but I split the table to create conditional field-level security (read-only unless one box was unchecked). However I'm trying to fix one flaw in the whole scheme: When a user adds a new record in...
|
by: Jerh9e1k5 |
last post by:
Hi there!
I'm trying to organize data into single line exports in order to take it out of a database.
The database contains customer information. Some customers have more than one "Business" phone number. I've managed to divide up the phone numbers into "Business" and "Business2" through a query which I then transformed into a table.
Now I want to use this new table to update the master table. Keep in mind that not all instances of...
|
by: boss1 |
last post by:
hi all,
i m new in php.i have a problem that is
i m using a php form where i can retrieve one field value from one table in oracle db by ajax and its working properly. but i need to insert the retrieved field value into another table from the same form.i m using session but not working.
how can i do this?can anyone please solve it for me.
Thanks.
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |