473,657 Members | 2,586 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Data Entry Form Problem

I have a data entry form with a combo box to look up an entrant's name.
If the name is already in the table then it pulls up the record and
that part of the form works fine. If the name isn't in the table then
I want to be able to add it but this part is not working. I enter a
name that is not in the table and press Enter. I step through the code
and it appears to work until I get to "Exit Sub". At this point a
warning message box appears with the message "Characters found after
end of SQL statement." and an OK button. When I click OK another
message box pops up with the message "The text you entered isn't an
item in the list. Select an item from the list, or enter text that
matches one of the listed items."; also, with an OK button. I click on
it and the yellow hi-lite goes away and nothing else occurs. I go to
the form itself and the combo box has the focus but the form is not on
a new record. If I press Enter the process will repeat itself. I know
I could already be finished if I had made it an unbound form and used
code but from some of the posts I have read on the bound vs. unbound
issue I wanted to learn how to do this the bound way. That way I could
have flexibility in what approach to take in the future. Below is my
code for the "beforeupda te" and "notinlist" events (once I had it
working I was going to rename my controls). I would appreciate it if
someone could tell me what I am doing wrong and how to correct it.

Private Sub Combo23_BeforeU pdate(Cancel As Integer)
On Error GoTo Err_Routine
'variable captures procedure name that error occurs in
strProcName = "Combo23_Before Update"

Me.RecordsetClo ne.FindFirst "[EntryName] = '" & Me![Combo23] & "'"
Me.Bookmark = Me.RecordsetClo ne.Bookmark

Exit_Routine:
Exit Sub
Err_Routine:
Select Case Err
Case Else
Err_General
End Select
Resume Exit_Routine
End Sub
Private Sub Combo23_NotInLi st(NewData As String, Response As Integer)
On Error GoTo Err_Routine
'variable captures procedure name that error occurs in
strProcName = "Combo23_NotInL ist"

Dim ctl As Control

' Return Control object that points to combo box.
Set ctl = Me!Combo23
' Prompt user to verify they wish to add new value.
If MsgBox("Value is not in list. Add it?", _
vbOKCancel) = vbOK Then
' Set Response argument to indicate that data
' is being added.
Response = acDataErrAdded
' Add string in NewData argument to row source.
ctl.RowSource = ctl.RowSource & ";" & NewData
Else
' If user chooses Cancel, suppress error message
' and undo changes.
Response = acDataErrContin ue
ctl.Undo
End If

Exit_Routine:
Exit Sub
Err_Routine:
Select Case Err
Case Else
Err_General
End Select
Resume Exit_Routine
End Sub
Thanks for any assistance,
Alex

Nov 13 '05 #1
1 2667

Alex,

Your issue is with the line:

ctl.RowSource = ctl.RowSource & ";" & NewData

If the RowSourceType property of your combobox is 'Table/Query', the
combobox is getting its list from a Table, Query or SQL statement. If
it is 'Value List', the rowsource is a string of elements separated by
semicolons (;).

It sounds like you are trying to add a element using the Value List
style to a SQL statement, wherein lies the problem. Jet interprets the
; as the end of a SQL statement, so it throws an error when it finds
text after the ;.

You really should be adding your new record to the underlying table.
There are many ways of doing this. Here is a simple form-based method:

DoCmd.GoToRecor d acDataForm, "YourEntryForm" , acNewRec
Me!EntryName = NewData
Me.Refresh ' Save the record
Combo23.Requery ' Update the combo

That should get you closer to your goal.

-Ken

Al***********@n cmail.net wrote:
I have a data entry form with a combo box to look up an entrant's name. If the name is already in the table then it pulls up the record and
that part of the form works fine. If the name isn't in the table then I want to be able to add it but this part is not working. I enter a
name that is not in the table and press Enter. I step through the code and it appears to work until I get to "Exit Sub". At this point a
warning message box appears with the message "Characters found after
end of SQL statement." and an OK button. When I click OK another
message box pops up with the message "The text you entered isn't an
item in the list. Select an item from the list, or enter text that
matches one of the listed items."; also, with an OK button. I click on it and the yellow hi-lite goes away and nothing else occurs. I go to
the form itself and the combo box has the focus but the form is not on a new record. If I press Enter the process will repeat itself. I know I could already be finished if I had made it an unbound form and used
code but from some of the posts I have read on the bound vs. unbound
issue I wanted to learn how to do this the bound way. That way I could have flexibility in what approach to take in the future. Below is my
code for the "beforeupda te" and "notinlist" events (once I had it
working I was going to rename my controls). I would appreciate it if
someone could tell me what I am doing wrong and how to correct it.

Private Sub Combo23_BeforeU pdate(Cancel As Integer)
On Error GoTo Err_Routine
'variable captures procedure name that error occurs in
strProcName = "Combo23_Before Update"

Me.RecordsetClo ne.FindFirst "[EntryName] = '" & Me![Combo23] & "'"
Me.Bookmark = Me.RecordsetClo ne.Bookmark

Exit_Routine:
Exit Sub
Err_Routine:
Select Case Err
Case Else
Err_General
End Select
Resume Exit_Routine
End Sub
Private Sub Combo23_NotInLi st(NewData As String, Response As Integer)
On Error GoTo Err_Routine
'variable captures procedure name that error occurs in
strProcName = "Combo23_NotInL ist"

Dim ctl As Control

' Return Control object that points to combo box.
Set ctl = Me!Combo23
' Prompt user to verify they wish to add new value.
If MsgBox("Value is not in list. Add it?", _
vbOKCancel) = vbOK Then
' Set Response argument to indicate that data
' is being added.
Response = acDataErrAdded
' Add string in NewData argument to row source.
ctl.RowSource = ctl.RowSource & ";" & NewData
Else
' If user chooses Cancel, suppress error message
' and undo changes.
Response = acDataErrContin ue
ctl.Undo
End If

Exit_Routine:
Exit Sub
Err_Routine:
Select Case Err
Case Else
Err_General
End Select
Resume Exit_Routine
End Sub
Thanks for any assistance,
Alex


Nov 13 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2035
by: edworboys | last post by:
I have designed a data entry form with a number of fields and a sub form. The first field (Country) is a combo box and the user selects a country. This, in turn reduces the number of options in the second field (Prospect Name). The user then uses the subform to enter a document location. The problem is this:
1
2205
by: Trent | last post by:
I am in the design phase of a new database and am having a devil of a time with a subform. I have three tables that relate to problem - Suppliers tbl, Customers tbl and a SuppliersCustomers tbl. The intent is to have the user enter in spend information by customer with each supplier. Sounds simple enough right? The common fields in each table are as follows:
6
2977
by: Wayne | last post by:
I am designing a database which needs approximately 50 fields per record. The database user requires data entry to be via a single screen. If I follow good database design practice and split the 50 fields into several smaller tables, is there any other way to enter the data on the single data entry screen other than having several subforms with the individual tables as their recordsource?
2
5049
by: filbennett | last post by:
Hi Everyone, I'm generally unfamiliar with Access form design, but have programmed Cold Fusion applications for a couple of years. I'd like to build a data entry form in Access that allows the following. First, the data schema: Three tables are involved. The first is a PERSONS table which has two fields, SSNUMBER (primary key), and NAME.
2
2121
by: Sethos | last post by:
I am sure that this has been covered, hashed, and rehashed, but a search on the group did not produce the answer, so forgive me if this seems like a "newbie" type question... Besically, I have a form on which the users can click on a button to add text boxes dynamically. That all works without a hitch. The problem comes in trying to verify the information in the boxes. Below is a very abbreviated example of the code I have in the form:
6
1927
by: Brian Blair | last post by:
I have created a input form that enters a number in a talble. If I open the form again it enters a new record instead of editing the existing record. It seems like it should be very basic but I see no way to do it other than a complicated macro.
1
4774
by: NumberCruncher | last post by:
Hi All, I am struggling with setting up my first system of tables, forms,and reports, and could use your help! I am setting up a database to keep track of the production of a produced item. The item is a panel, with a specific texture. There are standard panels that are then produced in a limited number of specific textures. The number of panels/project varies, so I keep track of the actual number of panels per project with the count:...
3
7493
by: bosmatthews | last post by:
I have a main form with a subform and a second subform nested to the first subform. The data entry property for all three forms (main, subform and sub-subform) is set to "yes" because I am intending this form to be used for data entry only. The main form has a combo box from which the user can select a lake. The first subform allows the user to enter survey data for the lake. The sub-subform allows the user to enter additional (plant...
2
2073
kcdoell
by: kcdoell | last post by:
Hello: I have four tables: tblDivision tblWorking_Region tblCredit_Region tblForecast (This is the main data entry table for all forecasting records) tblDivision has the following fields:
2
3075
by: AlexanderDeLarge | last post by:
Hi! I got a problem that's driving me crazy and I'm desperately in need of help. I'll explain my scenario: I'm doing a database driven site for a band, I got these tables for their discography section: Discography --------------------- DiscID
0
8392
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8305
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8730
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8503
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8605
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6163
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5632
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4301
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1607
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.