Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Checking a text box to make sure a code exists in our SQL Server
Sorry for posting this in two rooms. I couldn't help but notice that no
one's questions were answered on the other post. I am creating a data entry program that will check a premiumcode from our prmprdtbl before the operator advances to the next text field. I currently have it set up that if the operator types "PRM" into the transactiontype that the application will automatically insert some of the fields for the operator. Private Sub cboTransactiontype_LostFocus() If cboTransactiontype.Text = "NOM" Then cboPaymentType.Text = "NOM" txtTransAmount.Text = "0.00" cmdDESave.SetFocus ElseIf cboTransactiontype.Text = "PRM" Then cboPaymentType.Text = "NOM" txtTransAmount.Text = "0.00" txtTransPremCode.SetFocus End If End Sub However, when I try validating the premiumcode, It doesn't do what I'd like for it to do. Private Sub txtTransPremCode_LostFocus() If rstPremCode.State = adStateOpen Then rstPremCode.Close rstPremCode.Open "select * from prmprdtbl where prmcode = '" & txtTransPremCode.Text & "'", cn If rstPremCode.EOF = True Then MsgBox "You must insert a valid premium code here", vbInformation txtTransPremCode.SetFocus SendKeys "{Home}+{End}" Else txtTransPremCode.Text = UCase(txtTransPremCode.Text) txtTransQty.SetFocus End If End Sub It shows the messagebox even though I haven't advanced past it - or lost focus. It also won't highlight the txtTransPremCode field if I type a code in it that I know doesn't exist in the prmprdtbl. I seriously need some help. Any suggestions would be greatly appreciated. Thank you very much, Angelique |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Checking to see if a file exists. | Excel Discussion (Misc queries) | |||
Checking if Sheet Exists? | Excel Discussion (Misc queries) | |||
checking if an url exists | Excel Programming | |||
Checking to see if a worksheet exists | Excel Programming | |||
Checking to see if Folder exists | Excel Programming |