Link to home
Start Free TrialLog in
Avatar of Dan Flood
Dan Flood

asked on

newbie VB and SQL problem

Hi,

I have a form with a few textboxes for user input.  The form is to remove quantity from a pallet.  I cannot seem to figure out how to query my database and update the quantity based on this information.

I want to select palletid, quantity from tblPallets where palletid = txtpalletid.text and then subtract the value of val(txtQuantity.text) from that pallet.

But which object so i use?  Do i do it via code or those drop in objects from the toolbar?  How to I get a textbox value into one of those toolbar sql objects?

Frustrated,
Dan
:-)
Avatar of natloz
natloz

Well... a SQL statement would look like:

Dim strSQL as string

'Make sure it is number and not blank...
if IsNumeric(txtQuantity.text) and IsNumeric(txtPalletID.text) then
  if txtQuantity.text <> "" and txtPalletID <> "" then
     strSQL = "UPDATE tblPallets SET quantity = quantity - " & CInt(txtQuantity.text) & " where palletID = " & _
                    Cint(txtPalletID.text)
  endif
endif

then do a DataReader with EXECUTENONQuery to do the update...
ASKER CERTIFIED SOLUTION
Avatar of DotNetLover_Baan
DotNetLover_Baan

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Dan Flood

ASKER

Thank you - both answers helped - is there a way to split points?
You can split points.

Yes. Scroll down to the bottom of the question, just above the text box, and click the "Split Points" link. Select the radio button of the comment who you want to Accept as the Accepted Answer. Only one button can be selected. Set the point value (a text box above the comment) of how much you want this person to receive of the points. Then set the point values for each of the experts comments to whom you want to allocate points and these will be considered Assisted Answers in helping you resolve the issue. Double check your information and then click the Submit button at the bottom of the page. One note: the total points of the splits must equal the amount you asked the question for itself, and no person can receive fewer than 20 points.