473,404 Members | 2,195 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,404 software developers and data experts.

Problem with transferring date

I'm using a code to transfer data from a user form in excel to an access data base.

with rs
.addnew
.field ("status") =combobox1.value

All data tranfers when an entry is made in the combo/text box however a user may leave them blank. This then throws up a runtime error, can anybody help please.

Regards

nominoo
Jan 26 '10 #1
3 2527
Stewart Ross
2,545 Expert Mod 2GB
Hi Nominoo, and Welcome to Bytes!

What run-time error are you getting? Is it an Excel run-time error or an Access one?

It could be that your Access table's Status field is set not to allow null values (values which indicate that an entry has not been made yet). If this was the case, you could try using the Nz function to return a non-null value to your Status field. If Status is a text field (you don't say what type it is) then you could use Nz as follows:

Expand|Select|Wrap|Line Numbers
  1. .field("status") = Nz(Combobox1)
(The .value property does not normally have to be stated explicitly, as it is the default property returned when you refer to a control.)

If your Status field is a number, then Nz can be used to return 0 if a null is encountered. like this:

Expand|Select|Wrap|Line Numbers
  1. .field("status") = Nz(Combobox1, 0)
If it turns out that the null value in your combo box is not the issue here it would really help to know what the run-time error code and text is and which application is reporting it.

-Stewart
Jan 26 '10 #2
Hi Stweart

Thanks for reply, I am really new to doing this kind of thing and I'm really struggling at the mo.

I have set up a user form in excel, which has a number of combo boxes and textboxes which allows a user to input data. Some of the text boxes link to formulas in cells on the spreadsheet and show there values(it has just dawned on me that this maybe the problem).

The user doesn't have to complete all of the boxes so there maybe combo boxes text boxes left blank.

I then have a command button which is pressed to submit the data to an access database. If all combo boxes and textboxes have an entry in them the data is tranferred no problems, however if they don't have an entry I am receiving this error.

run-time error '-2147352571 (80020005)' type mis match (in excel)
Here is a condensed version it:

Private Sub CommandButton2_Click()
Dim cn As ADODB.Connection, rs As ADODB.Recordset
Set cn = New ADODB.Connection
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=\filepath.mdb"
Set rs = New ADODB.Recordset
rs.Open "Main", cn, adOpenKeyset, adLockOptimistic

With rs


.AddNew

.Fields("Status") = ComboBox1.Value
.Fields("RRR") = ComboBox46.Value
.Fields("RRS") = ComboBox52.Value
.Fields("SRR") = ComboBox47.Value
.Fields("SRS") = ComboBox53.Value
.Fields("WSR") = ComboBox48.Value
.Fields("WSS") = ComboBox108.Value
.Fields("WPR") = ComboBox110.Value
.Fields("WPS") = ComboBox112.Value
.Fields("WER") = ComboBox49.Value
.Fields("WES") = ComboBox54.Value

.Update
End With

rs.Close
Set rs = Nothing
cn.Close
Set cn = Nothing



MsgBox ("Your data has been sent")
UserForm_Initialize
End Sub
Jan 26 '10 #3
Stewart Ross
2,545 Expert Mod 2GB
I'd certainly try the Nz approach to see if this resolves the problem.

You would also benefit from setting a break point at your .Addnew statement and stepping through one line at a time to see if it fails at one particular blank combo, and to be able to test values using the immediate window.

There is an introductory article (one of a series) in our Insights section entitled Debugging in VBA which I have linked here for you, as you may well find it useful to know how to perform simple debugging steps.

-Stewart
Jan 26 '10 #4

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

Similar topics

3
by: Debaser | last post by:
Okay, I'm one error away from making this work. Here's my main(): int main(void) { size_t x; long y; long samples = { 10, 50, 100, 500, 1000, 5000, 10000, 50000, 100000, 500000, 1000000 }; ...
3
by: Chris K. | last post by:
Hi, Setting my first steps into Java, managing my genealogy website. In the list of names, with the names in anchor tags, i want a popup window to appear on clicking the name. With the command...
3
by: JGBNS via DotNetMonster.com | last post by:
Hi, I am new to this forumand I apologize as i am not a .net programmer but we have a program being developed by a .net programmer. Nowwe have run into an ftp snag and I think it is part ftp and...
15
by: Paul T. RONG | last post by:
Hello, I am making a restaurant database (it is much more complicated than I thought before!), now it comes to the last stage and I come across a problem. I will explain it in detail. In a...
2
by: vamsikrishna_b | last post by:
Hello all,the following problem i encountered while transferring data(mail ids) from MS-outlook to one application.Some mail ids after came into the application looked as strange characters.Eg are...
15
by: http://www.visual-basic-data-mining.net/forum | last post by:
Does anyone have any idea how to transferring data from TextBox1 in form1 to textBox2 in form2..... That means after i fill in any data in textBox1 and click Next button... It will bring me to...
1
by: jayantadutta | last post by:
hi i'm facing a problem while transferring date from csv to database. my quary as follows if (! firstdate.trim().equals("")) { System.out.println("insertInToDatabase startdate...
1
by: cloh | last post by:
I have a form in Access that generates an Excel Workbook with multiple worksheets. Each worksheet is unique to a particular location. The top row of each sheet shows the dates, the left-most column...
3
by: janetopps | last post by:
I have a news website, with asp pages, which was on Access, and i upgraded to MySQL, i used Bullzip to transfer the data. It had about 1000 pages, which im now able to pull up on the public side. Im...
3
by: angusfreefa | last post by:
Dear All, I am facing a problem of transferring data between 2 tables within the same database. I set up 2 tables. The first table is the permanent table (oos_table) for saving records. the...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.