Click here to Skip to main content
16,005,473 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Tab Control Navigation Pin
Robert Rohde25-Apr-05 19:59
Robert Rohde25-Apr-05 19:59 
QuestionHow to command the other control in a difference form in vb.net Pin
Mekong River25-Apr-05 15:58
Mekong River25-Apr-05 15:58 
AnswerRe: How to command the other control in a difference form in vb.net Pin
Dave Kreskowiak25-Apr-05 17:17
mveDave Kreskowiak25-Apr-05 17:17 
GeneralRe: How to command the other control in a difference form in vb.net Pin
Mekong River26-Apr-05 22:34
Mekong River26-Apr-05 22:34 
Generalcreating an employee database need code help please Pin
crshbrn1425-Apr-05 15:03
crshbrn1425-Apr-05 15:03 
GeneralRe: creating an employee database need code help please Pin
Dave Kreskowiak25-Apr-05 17:10
mveDave Kreskowiak25-Apr-05 17:10 
GeneralOpen two tables in one form Pin
msnick25-Apr-05 14:53
msnick25-Apr-05 14:53 
GeneralRe: Open two tables in one form Pin
Mike the Red27-Apr-05 9:33
Mike the Red27-Apr-05 9:33 
First of all, it sounds like you had a similar experience as I did - I entered the DB world after years of programming, and tried to do everything in Access using VBA. It worked, but not always efficiently. Eventually, I ran into problems where I was forced to learn about SQL and DBs. (If this isn't the case for you, excuse me.)

The point of all that is that what you are describing can easily be done with SQL.

First off, if you're looking to select all the records from Table1 where [Amount1] is less than [Amount2], and you don't need to display all the records from Table1, things will run much faster if you write a query in Access for this. If you use SQL view (the easiest for me to duplicate here), the SQL should look like this:
SELECT * FROM Table1 WHERE [Table1.Amount1] < [Table1.Amount2]

For this explanation, save this as DifferenceQuery.

If you only have a few records, you might not notice the speed difference. I am working in a medium sized database (30,000 records or so in the largest table, with 20+ fields in the table), and I quickly noticed the difference when creating my queries in Access rather than using ADO.

Then, in your program, to get the records you want from Table1, use ADO with SQL like:
SELECT [Info1], [Info2], [Amount1], [Amount2] FROM [DifferenceQuery]


This will return the same subset you currently acheive, only you don't have to programatically cycle through the records and select the ones where [Info1] < [Info2].

To place data from this subset into Table2, use ADO & SQL again:
dim info1 as string = "info1"
dim info2 as string = "info2"
dim amount1 as double = 1.1
dim amount2 as double = 2.0

dim sql as string
sql = "INSERT INTO [Table2] ([Info1], [Info2], [Amount1], [Amount2]) VALUES ('" & info1 & "', '" & info2 & "', " & amount1 & ", " & amount2 & ")"

The string concatenation can start to get confusing, but the above would (if I typed it right) produce the sql statement:
INSERT INTO [Table2] ([Info1], [Info2], [Amount1], [Amount2]) VALUES ('info1', 'info2', 1.1, 2.0)


Step through your subset and execute this SQL statement (substituting the appropriate values for your fields) and all your records will be added to table 2.

Hope this helps.

P.S.
I find w3school's SQL tutorials good reference, since I don't use all the SQL commands all the time: Link[^]
GeneralRe: Open two tables in one form Pin
msnick28-Apr-05 15:32
msnick28-Apr-05 15:32 
GeneralHi!!!Want some help!!! Pin
shekkk25-Apr-05 12:41
shekkk25-Apr-05 12:41 
GeneralRe: Hi!!!Want some help!!! Pin
Len Miller25-Apr-05 15:32
Len Miller25-Apr-05 15:32 
GeneralCalculating the latidude and longitude of an area Pin
Martin@captivasystems25-Apr-05 10:16
Martin@captivasystems25-Apr-05 10:16 
GeneralRe: Calculating the latidude and longitude of an area Pin
msnick25-Apr-05 15:52
msnick25-Apr-05 15:52 
GeneralRe: Calculating the latidude and longitude of an area Pin
Martin@captivasystems26-Apr-05 3:55
Martin@captivasystems26-Apr-05 3:55 
GeneralRe: Calculating the latidude and longitude of an area Pin
Martin@captivasystems26-Apr-05 11:52
Martin@captivasystems26-Apr-05 11:52 
GeneralRe: Calculating the latidude and longitude of an area Pin
msnick26-Apr-05 13:25
msnick26-Apr-05 13:25 
GeneralRe: Calculating the latidude and longitude of an area Pin
Martin@captivasystems27-Apr-05 3:14
Martin@captivasystems27-Apr-05 3:14 
Generalretrieving remote xml data Pin
Coreo25-Apr-05 6:30
Coreo25-Apr-05 6:30 
GeneralRe: retrieving remote xml data Pin
rudy.net26-Apr-05 18:42
rudy.net26-Apr-05 18:42 
GeneralRe: retrieving remote xml data Pin
Coreo27-Apr-05 14:36
Coreo27-Apr-05 14:36 
GeneralProblems with DSOFile 2.0 Pin
cad_guru25-Apr-05 6:00
cad_guru25-Apr-05 6:00 
GeneralRe: Problems with DSOFile 2.0 Pin
Dave Kreskowiak25-Apr-05 6:40
mveDave Kreskowiak25-Apr-05 6:40 
GeneralRe: Problems with DSOFile 2.0 Pin
cad_guru25-Apr-05 6:49
cad_guru25-Apr-05 6:49 
GeneralSleep and wake up Mode. Pin
Mkanchha25-Apr-05 5:00
Mkanchha25-Apr-05 5:00 
Generalapplication config Pin
Lisana25-Apr-05 4:27
Lisana25-Apr-05 4:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.