By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,187 Members | 1,659 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,187 IT Pros & Developers. It's quick & easy.

noob question: check if item exsists in table from value in textbox

P: n/a
I have a form with a query linked subform. Also on the form is a
textbox.

I want to pull up an AddItem subform if the data in the textbox does
not exsist in the table, and a UpdateItem subform if the item does
exsist.

I believe I would put the code in the AfterUpdate part of the textbox
function. With something like
If(Me.txtItem = "") Then
DoCmd.Openform("AddItem_subform")
Else
DoCmd.Openform("UpdateItem_subform")

Obviously this is psuedo-code, or I wouldn't be asking for help :)

Apr 21 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Try the DLookup() function to search the table for the value. You're correct
about using the textbox's AfterUpdate event.

Example:
If IsNull(DLookup("[FieldName]", "[TableName]", "[FieldName]=""" &
Me.txtMyTextbox & """") Then
DoCmd.OpenForm "AddItem_subform"
Else
DoCmd.OpenForm "UpdateItem_subform"
End If

This syntax assumes that the value in FieldName is a text value.

--
Wayne Morgan
MS Access MVP
"Stephen D Cook" <st******@comcast.net> wrote in message
news:qn********************************@4ax.com...
I have a form with a query linked subform. Also on the form is a
textbox.

I want to pull up an AddItem subform if the data in the textbox does
not exsist in the table, and a UpdateItem subform if the item does
exsist.

I believe I would put the code in the AfterUpdate part of the textbox
function. With something like
If(Me.txtItem = "") Then
DoCmd.Openform("AddItem_subform")
Else
DoCmd.Openform("UpdateItem_subform")

Obviously this is psuedo-code, or I wouldn't be asking for help :)

Apr 21 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.