Checking a text box to make sure a code exists in our SQL Server

This is a discussion on Checking a text box to make sure a code exists in our SQL Server within the ODBC forums in Framework and Interface Programming category; 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. ...

Go Back   Application Development Forum > Framework and Interface Programming > ODBC

Object Mix

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #1  
Old 05-31-2006, 02:55 PM
Angelique Worrell
Guest
 
Default Checking a text box to make sure a code exists in our SQL Server

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 With Quote
Reply


Thread Tools
Display Modes


All times are GMT -5. The time now is 12:35 AM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
vB Ad Management by =RedTyger=

In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.