Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > Database and Reporting > Confusing DB question...


Reply
 
Thread Tools Display Modes
  #1  
Old 05-12-2003, 01:11 AM
alvifarooq alvifarooq is offline
Junior Contributor
 
Join Date: Mar 2003
Posts: 205
Unhappy Confusing DB question...


hey guys...

ok see the attachments first for this...i have a picture of two tables that i have in access...

The user would select an Slp given in tblChemicalList after which we would only be concerned with that recordset...say the user selects S132100 thwn we would have that entire row as our chosen recordset...

If you see my code I try to compare then the fields of tblchemicallist starting from .Fields(2) that is HCl and compare each opf these fields with the values in the Chemical_Name column in tblDrugInfo...whereever i get an exact match I subtract the quantity in tblChemicalList from the one in tblDrugInfo under Current_Quantity...

I am not getting the code to wkr cause it gives me the eof bof error...plz check...

if u havent noticed yet this is kind of an inventory update system for chemicals in a lab...

dont pay heed to teh value cause i juggled arnd with many of em...check if i have the right logic!

Thanks...

Farooq.
Attached Images
File Type: jpg Tables.jpg (424.1 KB, 3 views)
Attached Files
File Type: txt Code.txt (948 Bytes, 2 views)
Reply With Quote
  #2  
Old 05-12-2003, 09:27 AM
Big Boabby's Avatar
Big Boabby Big Boabby is offline
Junior Contributor
 
Join Date: Apr 2002
Location: Scotland
Posts: 275
Default

Hi

Your code:

Code:
If Val(rsDrugInfo!Chemical_Name) = Val(rsChemicalList(Number).Name) Then
         rsDrugInfo!Curr_Quantity = Val(rsDrugInfo!Curr_Quantity) - Val(rsChemicalList!Fields(Number))
end if
I think the problem here is that you are trying to reference a value in rsChemicalList were in actual fact it is a field name. I have not tried any alternative syntax but I think it should go something like this:

Code:
If Val(rsDrugInfo!Chemical_Name) = rsChemicalList.Fields(Number).Name Then
	rsDrugInfo!Curr_Quantity = Val(rsDrugInfo!Curr_Quantity) - Val(rsChemicalList!Fields(Number))
end if
Hope this helps
__________________
As we sit bousin' at the nappy,
an' gettin fou, o unco happy
Reply With Quote
  #3  
Old 05-12-2003, 06:50 PM
alvifarooq alvifarooq is offline
Junior Contributor
 
Join Date: Mar 2003
Posts: 205
Default thanks...

i tried that code but it didn't do the trick...actually the problem with the if statement is that it is using chemicallist.fields(number).name and in the preceding sql statement i write:

sql2 = "SELECT ID, Slp FROM tblChemicalList WHERE Slp = '" & Tag & "' ORDER BY ID"


so there is no selection made for the fields(number) value...I get an error:

Item cannot be found in the collection

aside from that...teh subtraction is not carried out because no value exists for Val(rsChemicalList!Fields(Number)) for a similar reason...if anyone can help me answer these two specific queries, I would be grateful...

I think I just have to change the sql statement format to include all fields or smth...

Farooq.
Reply With Quote
  #4  
Old 05-12-2003, 07:27 PM
alvifarooq alvifarooq is offline
Junior Contributor
 
Join Date: Mar 2003
Posts: 205
Default answer...

ok so what i do is simply use this sql query:

sql2 = "SELECT * FROM tblChemicalList WHERE Slp = '" & Tag & "' ORDER BY ID"

all fields are selected and i can easily loop through...

Thanks a lot all ppl...

Farooq.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Question on Timers Zetsubo General 2 04-20-2003 03:12 PM
A Confusing Question Cobra_skd Miscellaneous Languages 2 01-08-2003 06:05 AM
VB question from newbie sunbin General 26 09-19-2002 01:07 AM
confusing question... :S spitsk8r General 10 06-12-2002 11:11 AM
Back button zukester General 31 08-15-2001 12:05 PM

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->