Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 788
Default populating data from excel into access

I have a excel user form that collects data and then drops it into an access
table. However if the user doesn't complete a field or leaves a field blank
then the code comes back with an error.



Dim db As DAO.Database
Set db = DAO.OpenDatabase("accessdatabase.mdb")
' Open the table
Dim rs As DAO.Recordset
Set rs = db.OpenRecordset("tblFOI")

' Write the data
rs.AddNew
rs!area = area_cbo.Text
rs!Officer = officer_txt.Text
rs!tel = tel_txt.Text
rs!Type = type_cbo.Text
rs!firstname = firstname_txt.Text
rs!lastname = lastname_txt.Text
rs!street = street_txt.Text
rs!town = town_txt.Text
rs!county = county_txt.Text
rs!postcode = postcode_txt.Text
rs!apptel = apptel_txt.Text
rs!fax = fax_txt.Text
rs!email = email_txt.Text
rs!Method = method_cbo.Text
rs!request = request_cbo.Text
rs!Description = description_txt.Text
rs!payment = payment_txt.Text
rs!methodreceived = methodreceived_cbo.Text
rs!datetohq = datetohq_txt.Text
rs!target = target_txt.Text
rs!sent = sent_txt.Text
rs!reasons = reasons_txt.Text


' Update the table
rs.Update
rs.Close
db.Close
Set rs = Nothing
Set db = Nothing

Any Ideas???

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default populating data from excel into access

Hi Chris

For examples see
http://www.erlandsendata.no/english/...php?t=envbadac



--
Regards Ron de Bruin
http://www.rondebruin.nl


"Chris" wrote in message ...
I have a excel user form that collects data and then drops it into an access
table. However if the user doesn't complete a field or leaves a field blank
then the code comes back with an error.



Dim db As DAO.Database
Set db = DAO.OpenDatabase("accessdatabase.mdb")
' Open the table
Dim rs As DAO.Recordset
Set rs = db.OpenRecordset("tblFOI")

' Write the data
rs.AddNew
rs!area = area_cbo.Text
rs!Officer = officer_txt.Text
rs!tel = tel_txt.Text
rs!Type = type_cbo.Text
rs!firstname = firstname_txt.Text
rs!lastname = lastname_txt.Text
rs!street = street_txt.Text
rs!town = town_txt.Text
rs!county = county_txt.Text
rs!postcode = postcode_txt.Text
rs!apptel = apptel_txt.Text
rs!fax = fax_txt.Text
rs!email = email_txt.Text
rs!Method = method_cbo.Text
rs!request = request_cbo.Text
rs!Description = description_txt.Text
rs!payment = payment_txt.Text
rs!methodreceived = methodreceived_cbo.Text
rs!datetohq = datetohq_txt.Text
rs!target = target_txt.Text
rs!sent = sent_txt.Text
rs!reasons = reasons_txt.Text


' Update the table
rs.Update
rs.Close
db.Close
Set rs = Nothing
Set db = Nothing

Any Ideas???



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 74
Default populating data from excel into access


Chris wrote:
if the user doesn't complete a field or leaves a field blank
then the code comes back with an error.

Any Ideas???


My idea is that the columns are defined as NOT NULL and have no DEFAULT
values.

Jamie.

--

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Populating a list/combo box with an Access column. kelsey Excel Discussion (Misc queries) 0 January 24th 07 03:19 PM
populating spreedsheet with data from access kuansheng Excel Worksheet Functions 0 February 3rd 06 04:03 AM
populating data from excel into access Chris Links and Linking in Excel 1 December 15th 04 07:50 AM
Populating worksheet with data from Access EManning Excel Programming 0 August 3rd 04 09:33 PM
Populating a lis/combo box in excel with access data Enrico Lisk Excel Programming 1 October 3rd 03 01:12 PM


All times are GMT +1. The time now is 09:08 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"