Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Checking to see if a file exists. JHB Excel Discussion (Misc queries) 3 August 5th 09 03:11 PM
Checking if Sheet Exists? [email protected] Excel Discussion (Misc queries) 5 September 1st 06 03:27 PM
checking if an url exists Aldo[_2_] Excel Programming 2 October 9th 05 10:20 PM
Checking to see if a worksheet exists Raman325[_27_] Excel Programming 7 August 19th 05 06:36 PM
Checking to see if Folder exists Dan[_25_] Excel Programming 2 September 24th 03 02:42 AM


All times are GMT +1. The time now is 12:02 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"