473,395 Members | 1,678 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,395 software developers and data experts.

Issue with Duplicate items on DoCmd.Close acForm command

My current code (which handles multiple string input's and creates individual fields based on the delimiter through the split() function is:
**Currently the DoCmd.Close is commented out.

Expand|Select|Wrap|Line Numbers
  1. Private Sub SaveInput_Click()
  2.  
  3. Dim InputString() As String
  4. Dim i As Integer
  5.  
  6. InputString = Split(InputName, " ")
  7. For i = 0 To UBound(InputString)
  8.     CurrentDb.Execute "INSERT INTO InventoryInputT(InputID) VALUES ('" & InputString(i) & "')"
  9. Next i
  10.  
  11.  
  12. 'DoCmd.Close acForm, "InventoryInputF"'
  13.  
  14. End Sub
  15.  
Therefore, if I enter 'data1 data2 data3' in the assigned textbox the result in my table is as expected:
field1 data1
field2 data2
field3 data3

My perplexing issue is, if I uncomment the DoCmd.Close acForm."InventoryInputF" which I wrote purely to close the form after saving.... it table now displays the results

field1 data1 data2 data3
field2 data1
field3 data2
field4 data3

You can see that for some reason when I implement the docmd.close code, the data is saved both as its 'lump sum' of all the values IN ADDITION to its proper function of using the split() function.

Anybody have any ideas why? Or maybe another way to close my form with code so I can avoid the DoCmd.Close code??
Apr 25 '17 #1

✓ answered by NeoPa

That smells very heavily of a bound form to me. With something like this you don't want a bound form.

4 912
Disregard,

I had an 'undue button' that ran a macro to navigate to a 'new record' when clicked. I didn't realize this worked to 'save what was in the textbox' before moving to a new record.

I switched the macro for
textboxname.value = null and it seems to have solved the issue...

However I'm not sure why that macro for a 'undo' button would affect the code for my 'save input' button and why the 'docmd.close acform' was affected...

The only reasoning to me is that when the 'docmd.close acform' ran, the macro regarded that as altering the information thus saved the total textbox information... effectively saving the split() information from my save button and the lump sum informaiton from my undue button
Apr 25 '17 #2
Disregard the Disregard,

the code above hasn't been changed. The macro mentioned in the disregard is still there.

The issue appears whenever I close the form. For example, I enter "data1 data2 data3" and press save, the data saves as 3 individual fields as I want, with "data1 data2 data3" still appearing in the textbox. There is no issue here.

Once I close the form, if the "data1 data2 data3" is still in the textbox, then that information is saved to the table in one field displaying data1 data2 data3.

I have implemented textboxname.value=null after my split() function so that there is never information remaining in the box... but then when I close the form a record with zero input is saved to my table!

In Summary, whenever I close the form, whatever is in the textbox is saved to the table, even if there is nothing there... how can I solve this?
Apr 25 '17 #3
NeoPa
32,556 Expert Mod 16PB
That smells very heavily of a bound form to me. With something like this you don't want a bound form.
Apr 25 '17 #4
jforbes
1,107 Expert 1GB
I would agree with Neopa that you really don't need a bound Form. Especially if you look at the code, no controls are ever referenced. Your blank record and possible missing record in code are unrelated problems.
Apr 28 '17 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: chanchito_cojones | last post by:
hi there, I am needing some help with a database I am putting together. The database works off of a main Form, which then has buttons on it that will open up other forms. The problem I am having...
1
by: pcb | last post by:
Hi All, I have a multi-select listbox, that can have duplicate items (i.e samples numbers that are analyzed in duplicate - the sample IDs are not the same, but these IDs are hidden from the...
10
by: Adam Clauss | last post by:
I have a page containing a list box. This list may contain duplicate items - in which the ORDER is important. ex: a b b a is significant as compared to: b
5
by: mamatha | last post by:
Hi I am developing a VB.NET application,in that application i have a listbox.When adding items to the listbox some duplicate items are added,how can i prevent listbox items from duplication.If...
4
by: Shi Mu | last post by:
I used the following method to remove duplicate items in a list and got confused by the error. >>> a , , ] >>> noDups='] ] Traceback (most recent call last): File "<interactive input>", line...
0
by: Jon LaRosa | last post by:
I just spent about 2 hours pulling my hair out over this issue, and I don't want it to happen to anyone else ever again. Ever. Basically you try to close a form using "DoCmd.Close", the form has...
3
by: Jim McGivney | last post by:
In VWD I have an aspx page with a DropDownList control. The DropDownList is populated from a column from a table in an Access database. If there are duplicate values in the column they are added...
4
by: ejack | last post by:
int total = static_cast<int>(vComp.size()) - 1; int tTotalUnits = 0; float tTotalCostJob = 0; int i = 0; int j = 0; int counter = 0; bool foundFlag; vector<string> vItems;...
2
by: Dan2kx | last post by:
Hi gang, i have yet another curious question for the panel... i have a userform that seems to be disobeying the docmd.close acform, "FormName" i give it, either on a button or in a...
5
by: mabrynda | last post by:
Good morning everybody, I'm trying to use a string variable inside the DoCmd.Close statement. Despite many attempts this doesn't work. Does anybody have a solution for that? I have a form called...
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...
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
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,...
0
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...
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...
0
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...
0
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...

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.