Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Verify against a table push a msgbox and open form

Status
Not open for further replies.

Styrker

Technical User
Sep 18, 2002
9
US
OK if you all are confused by my subject read on. Because I am really confused.

Here is what I am trying to do:

I have a text box (text14)in a form (jobs). I need to verify the data input in text14 against data in a specific row (colornumber) in table (color). If text14 does not match colornumber I need a msgbox to state the colornumber does not exist and when OK is pressed for the color form to orpen for data input.

Can this be done?
Am I going about this the wrong way?
Am I trying to reinvent the wheel somewhere?

I have tried several If Then statements with no effect.

Any and all help will be greatly appreciated.

 
Hi

Unless I'm missing something, it just sounds like regular run of the mill dB stuff.

Something like this should do the job

--------
Sub Whatever()

Dim intColor as integer
Dim strSQL as string
Dim dB as Database
Dim Rec as Recordset

intColor = txtColor
strSQL = "Select Count(ColorNumber) from [Color] where ColorNumber = " & intColor & " "

Set db = CurrentDb
Set rec = db.OpenRecordset(strSQL, dbOpenDynaset)

With rec
if .recordcount > 0 then Exit Sub
End With

MsgBox"Your Msg"
DoCmd.OpenForm "YourForm"
Exit Sub
End Sub
----------------

I apologise if the code's a bit ragged, I just typed it off the bat.

Hope this is what you'er looking for.
AutumnBlues
 
Hi

Unless I'm missing something, it just sounds like regular run of the mill dB stuff.

Something like this should do the job

--------
Sub Whatever()

Dim intColor as integer
Dim strSQL as string
Dim dB as Database
Dim Rec as Recordset

intColor = txtColor
strSQL = "Select Count(ColorNumber) from [Color] where ColorNumber = " & intColor & " "

Set db = CurrentDb
Set rec = db.OpenRecordset(strSQL, dbOpenDynaset)

With rec
if .recordcount > 0 then Exit Sub
End With

MsgBox"Your Msg"
DoCmd.OpenForm "YourForm"
Exit Sub
End Sub
----------------

I apologise if the code's a bit ragged, I just typed it off the bat.

Hope this is what you're looking for.
AutumnBlues
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top