PC Review


Reply
Thread Tools Rate Thread

Copy Data into Database gives error

 
 
bactfarmer
Guest
Posts: n/a
 
      24th Mar 2007
I'm creating a macro to copy information entered into a form and
put it into a database. It works fine as long as the first row of
information is filled out in the database. If the no information has
been added to the database yet I get Run-Time Error 1004 Application
Defined or Object Defined Error. What can I change to correct this
from happening

Sheets("Form").Select
Range("A6:X20").Select
Selection.Copy
Sheets("Database").Select
Range("A10").Select
Selection.End(xlDown).Offset(1, 0).Select
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Selection.End(xlDown).Select

 
Reply With Quote
 
 
 
 
Coza
Guest
Posts: n/a
 
      24th Mar 2007
maybe add a :
If Range("A6:X20").value <>"" then
Selection.Copy
Sheets("Database").Select
Range("A10").Select
Selection.End(xlDown).Offset(1, 0).Select
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Selection.End(xlDown).Select
else
msgbox "There is No Value in the range !!"
end if

"bactfarmer" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> I'm creating a macro to copy information entered into a form and
> put it into a database. It works fine as long as the first row of
> information is filled out in the database. If the no information has
> been added to the database yet I get Run-Time Error 1004 Application
> Defined or Object Defined Error. What can I change to correct this
> from happening
>
> Sheets("Form").Select
> Range("A6:X20").Select
> Selection.Copy
> Sheets("Database").Select
> Range("A10").Select
> Selection.End(xlDown).Offset(1, 0).Select
> Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone,
> SkipBlanks _
> :=False, Transpose:=False
> Selection.End(xlDown).Select
>



 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      24th Mar 2007
Maybe you could start at the bottom of column A and go up to find the last used
cell in that row, then come down one row.

Dim RngToCopy as Range
Dim DestCell as range

with worksheets("form")
set rngtocopy = .range("a6:X20")
end with

with worksheets("Database")
set destcell = .cells(.rows.count,"A").end(xlup).offset(1,0)
end with

rngtocopy.copy _
destination:=destcell



bactfarmer wrote:
>
> I'm creating a macro to copy information entered into a form and
> put it into a database. It works fine as long as the first row of
> information is filled out in the database. If the no information has
> been added to the database yet I get Run-Time Error 1004 Application
> Defined or Object Defined Error. What can I change to correct this
> from happening
>
> Sheets("Form").Select
> Range("A6:X20").Select
> Selection.Copy
> Sheets("Database").Select
> Range("A10").Select
> Selection.End(xlDown).Offset(1, 0).Select
> Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone,
> SkipBlanks _
> :=False, Transpose:=False
> Selection.End(xlDown).Select


--

Dave Peterson
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to copy the data's from one database to another database? lvensen Microsoft Access 3 2nd Jul 2009 11:06 AM
how do you copy a database but not copy the data? =?Utf-8?B?Qm9iYmkgQg==?= Microsoft Access Database Table Design 1 24th Feb 2005 05:27 PM
copy data from one database to another database tom Microsoft Dot NET Framework 1 27th Oct 2003 09:03 PM
copy data from one database to another database S Gopikrishna Microsoft Dot NET Framework 0 22nd Oct 2003 07:51 PM
Re: copy data from one database to another database Girish Bharadwaj Microsoft Dot NET Framework 0 22nd Oct 2003 02:28 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:05 AM.