473,387 Members | 1,650 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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

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
1 1342
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Orion | last post by:
Hi, This is kind of last minute, I have a day and a half left to figure this out. I'm working on a project using ms-sqlserver. We are creating a ticket sales system, as part of the system, I...
0
by: Michelle Keys | last post by:
I am trying to call a print function to print a string from a database using javascript. Which is RC_DATA of Varchar2(2500). This is a javascript is not being used. I have a thing that needs to...
1
by: Fraggle | last post by:
I have a repeater with controls added at run time. the <template> also contains a <asp:textbox that is made visible on some repeater elements. when I come to read the text info out it has...
1
by: bill yeager | last post by:
I'm doing an inline edit of an Admin table using the Datagrid. There are three columns in my Admin table. I want to dynamically disable the corresponding "CareType" field (see below) in the grid...
6
by: Joe | last post by:
Hi, I have a MS Access DB in which a record has just too many fields to be able to allow users to do inline editing in a datagrid. So I want to display as First Name: Text box where first...
2
by: Frank | last post by:
Hello, I am developing with VS.Net 2003 on the asp 1.1 platform. I am a few days new to using a datagrid. I found a nice tutorial and had no problems using an editable datagrid with textboxes...
2
by: Bubb | last post by:
I have an Access database with one table that I use for stuff I sell online. Each record has the following fields: Unique Id, Cost, and Item Description. I just obtained some more stuff with its...
1
by: psymon25 | last post by:
Hi All I posted the below on MSDN and nothing so far so I hope someone here can help: This is my first time working with XML so please bare with me I have a form with 18 textboxes and i can...
3
by: Nimion | last post by:
Sorry if I posted in the wrong forum, but since I'm looking at VB code I have a 50/50 chance at being wrong. :) I've been trying a variety of methods to speed up the checking for duplicates. ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.