A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Inserting Data from form into table



 
 
Thread Tools Display Modes
  #1  
Old March 18th, 2010, 04:53 PM posted to microsoft.public.access.forms
jrp444
external usenet poster
 
Posts: 36
Default Inserting Data from form into table

I am trying to populate a table from a form that I am pulling information in
from other tables. I am trying to get it when I enter the date that it will
insert the information into the table. I am getting an errror (There was an
error adding the record.3001, Arguments are of the wrong tyype, are out of
acceptable range, or are in conflict with one another). I have check the
spell and the names in my module and every thing seems to be ok. Could
somebody please help me firgure out why I am getting this error. Below is my
Module:
Private Sub dated_AfterUpdate()

Dim sql As String
Dim rsAdd As New ADODB.Recordset

On Error GoTo DbError
'Assign updatable cursor and lock type properties.

rsAdd.CursorType = adOpenDynamic
rsAdd.LockType = adLockOptimistic
'Opening recordset object

rsAdd.Open "tbl_Issued", remoteConnection, , , adCmdTable

With rsAdd
..AddNew

!ID = Me.ID
!Commodity = Me.txt_comm
!Trailer_no = Me.txt_Trl_no
!county = Me.txt_county
!driver = Me.txt_driver
!Web_EOC = Me.txt_eoc
!D_Date = Me.dated



..Update
..Close
End With
MsgBox "Record Added.", vbInformation

'‘Close the form-level Recordset object and refresh
'‘it to include the newly updated row.
'rsAdjustors.Close
'SetRecordset

Exit Sub

DbError:

MsgBox "There was an error adding the record." _
& Err.Number & ", " & Err.Description
End Sub


Thanks!
  #2  
Old March 18th, 2010, 06:22 PM posted to microsoft.public.access.forms
sweet_dreams
external usenet poster
 
Posts: 10
Default Inserting Data from form into table

Could somebody please help me firgure out why I am getting this error.

I think that problem is that all control values are stored as variants
and when you have tabel where all fields have defined data type,
before inserting value you have to convert it to proper datatype. Try
to debug your your code and see where the error occours, which value
causes error. Then try to convert this value to proper datatype.

Regards,
Sebastian

  #3  
Old March 18th, 2010, 07:29 PM posted to microsoft.public.access.forms
Jeff Boyce
external usenet poster
 
Posts: 8,621
Default Inserting Data from form into table

From your description, it sounds like you are trying to:
* gather information from some tables, and
* duplicate that information in another table

If so, why?! You might do something like that if you were using Excel...
but Access is NOT a spreadsheet.

If you'll provide a more specific description of what data you have and what
business need you are trying to solve, folks here may be able to offer more
specific suggestions.

Regards

Jeff Boyce
Microsoft Access MVP

--
Disclaimer: This author may have received products and services mentioned
in this post. Mention and/or description of a product or service herein
does not constitute endorsement thereof.

Any code or pseudocode included in this post is offered "as is", with no
guarantee as to suitability.

You can thank the FTC of the USA for making this disclaimer
possible/necessary.


"jrp444" wrote in message
...
I am trying to populate a table from a form that I am pulling information
in
from other tables. I am trying to get it when I enter the date that it
will
insert the information into the table. I am getting an errror (There was
an
error adding the record.3001, Arguments are of the wrong tyype, are out of
acceptable range, or are in conflict with one another). I have check the
spell and the names in my module and every thing seems to be ok. Could
somebody please help me firgure out why I am getting this error. Below is
my
Module:
Private Sub dated_AfterUpdate()

Dim sql As String
Dim rsAdd As New ADODB.Recordset

On Error GoTo DbError
'Assign updatable cursor and lock type properties.

rsAdd.CursorType = adOpenDynamic
rsAdd.LockType = adLockOptimistic
'Opening recordset object

rsAdd.Open "tbl_Issued", remoteConnection, , , adCmdTable

With rsAdd
.AddNew

!ID = Me.ID
!Commodity = Me.txt_comm
!Trailer_no = Me.txt_Trl_no
!county = Me.txt_county
!driver = Me.txt_driver
!Web_EOC = Me.txt_eoc
!D_Date = Me.dated



.Update
.Close
End With
MsgBox "Record Added.", vbInformation

''Close the form-level Recordset object and refresh
''it to include the newly updated row.
'rsAdjustors.Close
'SetRecordset

Exit Sub

DbError:

MsgBox "There was an error adding the record." _
& Err.Number & ", " & Err.Description
End Sub


Thanks!



  #4  
Old March 18th, 2010, 07:59 PM posted to microsoft.public.access.forms
jrp444
external usenet poster
 
Posts: 36
Default Inserting Data from form into table

You are probably right except I do not know how to make the debug mode work
when I am in the form. It will not run the module in module mode. Also, how
to change the data type in the module.

"sweet_dreams" wrote:

Could somebody please help me firgure out why I am getting this error.


I think that problem is that all control values are stored as variants
and when you have tabel where all fields have defined data type,
before inserting value you have to convert it to proper datatype. Try
to debug your your code and see where the error occours, which value
causes error. Then try to convert this value to proper datatype.

Regards,
Sebastian

.

  #5  
Old March 18th, 2010, 08:32 PM posted to microsoft.public.access.forms
jrp444
external usenet poster
 
Posts: 36
Default Inserting Data from form into table

I have a form that indiviuals will fill in that uses combo boxes and other
data that is needed and I want to take this information an put it into a
table that I can use to run other macros and reports.


"Jeff Boyce" wrote:

From your description, it sounds like you are trying to:
* gather information from some tables, and
* duplicate that information in another table

If so, why?! You might do something like that if you were using Excel...
but Access is NOT a spreadsheet.

If you'll provide a more specific description of what data you have and what
business need you are trying to solve, folks here may be able to offer more
specific suggestions.

Regards

Jeff Boyce
Microsoft Access MVP

--
Disclaimer: This author may have received products and services mentioned
in this post. Mention and/or description of a product or service herein
does not constitute endorsement thereof.

Any code or pseudocode included in this post is offered "as is", with no
guarantee as to suitability.

You can thank the FTC of the USA for making this disclaimer
possible/necessary.


"jrp444" wrote in message
...
I am trying to populate a table from a form that I am pulling information
in
from other tables. I am trying to get it when I enter the date that it
will
insert the information into the table. I am getting an errror (There was
an
error adding the record.3001, Arguments are of the wrong tyype, are out of
acceptable range, or are in conflict with one another). I have check the
spell and the names in my module and every thing seems to be ok. Could
somebody please help me firgure out why I am getting this error. Below is
my
Module:
Private Sub dated_AfterUpdate()

Dim sql As String
Dim rsAdd As New ADODB.Recordset

On Error GoTo DbError
'Assign updatable cursor and lock type properties.

rsAdd.CursorType = adOpenDynamic
rsAdd.LockType = adLockOptimistic
'Opening recordset object

rsAdd.Open "tbl_Issued", remoteConnection, , , adCmdTable

With rsAdd
.AddNew

!ID = Me.ID
!Commodity = Me.txt_comm
!Trailer_no = Me.txt_Trl_no
!county = Me.txt_county
!driver = Me.txt_driver
!Web_EOC = Me.txt_eoc
!D_Date = Me.dated



.Update
.Close
End With
MsgBox "Record Added.", vbInformation

''Close the form-level Recordset object and refresh
''it to include the newly updated row.
'rsAdjustors.Close
'SetRecordset

Exit Sub

DbError:

MsgBox "There was an error adding the record." _
& Err.Number & ", " & Err.Description
End Sub


Thanks!



.

  #6  
Old March 18th, 2010, 08:34 PM posted to microsoft.public.access.forms
jrp444
external usenet poster
 
Posts: 36
Default Inserting Data from form into table

I found that the following line gives me this error:

rsAdd.Open "[Issued]", remoteConnection, , , adCmdTable

The Issued is the table that I want to put the information into.

"sweet_dreams" wrote:

Could somebody please help me firgure out why I am getting this error.


I think that problem is that all control values are stored as variants
and when you have tabel where all fields have defined data type,
before inserting value you have to convert it to proper datatype. Try
to debug your your code and see where the error occours, which value
causes error. Then try to convert this value to proper datatype.

Regards,
Sebastian

.

  #7  
Old March 18th, 2010, 08:51 PM posted to microsoft.public.access.forms
Jeff Boyce
external usenet poster
 
Posts: 8,621
Default Inserting Data from form into table

Bear in mind that you don't need to have a table with data laid out for your
report. One of the many nice features of a relational database like Access
is that you can use a query to join related tables, collecting the data you
need, then basing a report on that query, rather than on a table.

Good luck!

Regards

Jeff Boyce
Microsoft Access MVP

--
Disclaimer: This author may have received products and services mentioned
in this post. Mention and/or description of a product or service herein
does not constitute endorsement thereof.

Any code or pseudocode included in this post is offered "as is", with no
guarantee as to suitability.

You can thank the FTC of the USA for making this disclaimer
possible/necessary.

"jrp444" wrote in message
...
I have a form that indiviuals will fill in that uses combo boxes and other
data that is needed and I want to take this information an put it into a
table that I can use to run other macros and reports.


"Jeff Boyce" wrote:

From your description, it sounds like you are trying to:
* gather information from some tables, and
* duplicate that information in another table

If so, why?! You might do something like that if you were using Excel...
but Access is NOT a spreadsheet.

If you'll provide a more specific description of what data you have and
what
business need you are trying to solve, folks here may be able to offer
more
specific suggestions.

Regards

Jeff Boyce
Microsoft Access MVP

--
Disclaimer: This author may have received products and services mentioned
in this post. Mention and/or description of a product or service herein
does not constitute endorsement thereof.

Any code or pseudocode included in this post is offered "as is", with no
guarantee as to suitability.

You can thank the FTC of the USA for making this disclaimer
possible/necessary.


"jrp444" wrote in message
...
I am trying to populate a table from a form that I am pulling
information
in
from other tables. I am trying to get it when I enter the date that it
will
insert the information into the table. I am getting an errror (There
was
an
error adding the record.3001, Arguments are of the wrong tyype, are out
of
acceptable range, or are in conflict with one another). I have check
the
spell and the names in my module and every thing seems to be ok. Could
somebody please help me firgure out why I am getting this error. Below
is
my
Module:
Private Sub dated_AfterUpdate()

Dim sql As String
Dim rsAdd As New ADODB.Recordset

On Error GoTo DbError
'Assign updatable cursor and lock type properties.

rsAdd.CursorType = adOpenDynamic
rsAdd.LockType = adLockOptimistic
'Opening recordset object

rsAdd.Open "tbl_Issued", remoteConnection, , , adCmdTable

With rsAdd
.AddNew

!ID = Me.ID
!Commodity = Me.txt_comm
!Trailer_no = Me.txt_Trl_no
!county = Me.txt_county
!driver = Me.txt_driver
!Web_EOC = Me.txt_eoc
!D_Date = Me.dated



.Update
.Close
End With
MsgBox "Record Added.", vbInformation

''Close the form-level Recordset object and refresh
''it to include the newly updated row.
'rsAdjustors.Close
'SetRecordset

Exit Sub

DbError:

MsgBox "There was an error adding the record." _
& Err.Number & ", " & Err.Description
End Sub


Thanks!



.



  #8  
Old March 18th, 2010, 09:32 PM posted to microsoft.public.access.forms
jrp444
external usenet poster
 
Posts: 36
Default Inserting Data from form into table

I do know that but I am trying to do this from a form so others can fill it
in and see what they have done.

"Jeff Boyce" wrote:

Bear in mind that you don't need to have a table with data laid out for your
report. One of the many nice features of a relational database like Access
is that you can use a query to join related tables, collecting the data you
need, then basing a report on that query, rather than on a table.

Good luck!

Regards

Jeff Boyce
Microsoft Access MVP

--
Disclaimer: This author may have received products and services mentioned
in this post. Mention and/or description of a product or service herein
does not constitute endorsement thereof.

Any code or pseudocode included in this post is offered "as is", with no
guarantee as to suitability.

You can thank the FTC of the USA for making this disclaimer
possible/necessary.

"jrp444" wrote in message
...
I have a form that indiviuals will fill in that uses combo boxes and other
data that is needed and I want to take this information an put it into a
table that I can use to run other macros and reports.


"Jeff Boyce" wrote:

From your description, it sounds like you are trying to:
* gather information from some tables, and
* duplicate that information in another table

If so, why?! You might do something like that if you were using Excel...
but Access is NOT a spreadsheet.

If you'll provide a more specific description of what data you have and
what
business need you are trying to solve, folks here may be able to offer
more
specific suggestions.

Regards

Jeff Boyce
Microsoft Access MVP

--
Disclaimer: This author may have received products and services mentioned
in this post. Mention and/or description of a product or service herein
does not constitute endorsement thereof.

Any code or pseudocode included in this post is offered "as is", with no
guarantee as to suitability.

You can thank the FTC of the USA for making this disclaimer
possible/necessary.


"jrp444" wrote in message
...
I am trying to populate a table from a form that I am pulling
information
in
from other tables. I am trying to get it when I enter the date that it
will
insert the information into the table. I am getting an errror (There
was
an
error adding the record.3001, Arguments are of the wrong tyype, are out
of
acceptable range, or are in conflict with one another). I have check
the
spell and the names in my module and every thing seems to be ok. Could
somebody please help me firgure out why I am getting this error. Below
is
my
Module:
Private Sub dated_AfterUpdate()

Dim sql As String
Dim rsAdd As New ADODB.Recordset

On Error GoTo DbError
'Assign updatable cursor and lock type properties.

rsAdd.CursorType = adOpenDynamic
rsAdd.LockType = adLockOptimistic
'Opening recordset object

rsAdd.Open "tbl_Issued", remoteConnection, , , adCmdTable

With rsAdd
.AddNew

!ID = Me.ID
!Commodity = Me.txt_comm
!Trailer_no = Me.txt_Trl_no
!county = Me.txt_county
!driver = Me.txt_driver
!Web_EOC = Me.txt_eoc
!D_Date = Me.dated



.Update
.Close
End With
MsgBox "Record Added.", vbInformation

''Close the form-level Recordset object and refresh
''it to include the newly updated row.
'rsAdjustors.Close
'SetRecordset

Exit Sub

DbError:

MsgBox "There was an error adding the record." _
& Err.Number & ", " & Err.Description
End Sub


Thanks!


.



.

  #9  
Old March 19th, 2010, 01:55 AM posted to microsoft.public.access.forms
John W. Vinson
external usenet poster
 
Posts: 18,261
Default Inserting Data from form into table

On Thu, 18 Mar 2010 13:32:06 -0700, jrp444
wrote:

I have a form that indiviuals will fill in that uses combo boxes and other
data that is needed and I want to take this information an put it into a
table that I can use to run other macros and reports.


Do you have some specific reason not to use a form *bound to the table*, so
Access will do all the work for you and not need any code at all?
--

John W. Vinson [MVP]
 




Thread Tools
Display Modes

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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


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


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