Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
djbomb95
Starting Member
9 Posts |
Posted - 2012-09-07 : 23:57:25
|
Private Sub btnAddPizza_Click()Dim strBase As StringDim strSize As StringDim intPrice As IntegerDim intSizeError As IntegerDim intBaseError As IntegerTryagain:strSize = InputBox("Type the size. Either:" & vbNewLine & "1 for small " & vbNewLine & "2 for Medium " & vbNewLine & "3 for Large", "Choose Size")If strSize = "1" Then intPrice = 6ElseIf strSize = "2" Then intPrice = 7ElseIf strSize = "3" Then intPrice = 8ElsestrSizeError = MsgBox("You must enter either 1, 2 or 3. Try Again?", vbYesNo, "Oops!")If strSizeError = vbYes ThenGoTo TryagainElseGoTo NoPizzaEnd IfEnd IfTryagain2:strBase = InputBox("Type the name of the base. Either:" & vbNewLine & "1 for Cheesy " & vbNewLine & "2 for Classic" & vbNewLine & "3 for Thin", "Choose Base")If strBase = "1" Then intPrice = intPrice + 1 ElseIf strSize = "2" Then intPrice = intPrice ElseIf strSize = "3" Then intPrice = intPriceElsestrSizeError = MsgBox("You must enter either 1, 2 or 3. Try Again?", vbYesNo, "Oops!")If strBaseError = vbYes ThenGoTo Tryagain2ElsestrSize = ""GoTo NoPizzaEnd IfEnd IfIf strBase = "1" ThenstrBase = "Cheesy"ElseIf strSize = "2" Then strBase = "Classic"ElseIf strSize = "3" Then strBase = "Thin"End IfIf strSize = "1" Then strSize = "S"ElseIf strSize = "2" Then strSize = "M"ElseIf strSize = "3" Then strSize = "L"End IfDoCmd.RunSQL "INSERT INTO PizzaOrder (PizzaName, PizzaBase, OrderID, Special, PizzaSize, Price) VALUES ('" & lstPizzaMenu & "', '" & strBase & "', " & txtOrderID & ", No, '" & strSize & "', " & intPrice & ");"lstPizzasAdded.RequeryNoPizza:End SubThis sub does work on the condition that both input boxes have the same values put into them. Basically, I click the button, and two boxes pop up saying enter your value. You type in 1, 2 or 3 for small to large respectively and you type the same for cheesy to thin aswell. This basically gathers all the information that isn't already on the form to insert a row into my table. As I said before, it does work if both values are the same (I have to type 1 in the first box and 1 in the second). Is there any way anyone knows to fix this? |
|
chadmat
The Chadinator
1974 Posts |
Posted - 2012-09-08 : 00:55:29
|
What happens if they are not the same? Can you set a breakpoint and step thru it and see what is hapening?-Chad |
|
|
djbomb95
Starting Member
9 Posts |
Posted - 2012-09-08 : 02:44:18
|
Hey there Chad, I have just taken a long hard glance at the code, and I have found that I must have copied and pasted but not transposed, because the second Select Case statement is not not consistently strBase, it has two of the strSize in it. I have fixed this issue, but I will post again in this thread if I come across other problems in relation to this sub. Thanks for the guidance, it was through analysing properly that I found the error. |
|
|
|
|
|
|
|