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

Help with error 2448: You can't assign value to this object

I need help with error 2448: You can't assign value to this object. What I am trying to do is allow user to select event id and race id from combo option. Once the user selects those, then the id associated with those is suppose to be carried over to a new form which should associated those two ids with runner id from runner table. Thus, I will have all three ids in event-race-runner table (which is an associative table). However when I do that I get the error message which does not let me insert the ids into this new table. I have attached the codes below. All id are number. The main table ids were generated automatically.

This is the code which should carry the ids:
Private Sub cmdAddRaceRunner_Click()
DoCmd.OpenForm "Input Runner for race", , , , acFormAdd, , OpenArgs:=cmbErEventid & "|" & cmbErRaceid
end sub

this is the form which should have assigned the id into the new table:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Load()
  2.     If Len(Me.OpenArgs & "") > 0 Then
  3.     Dim i As Integer
  4.     Dim s As String
  5.     Dim x As String
  6.     Dim y As Integer
  7.     Dim a As String
  8.     Dim b As Integer
  9.  
  10.     s = CStr(Me.OpenArgs)
  11.     i = InStr(1, s, "|")
  12.  
  13.     x = Left(s, i - 1)
  14.     y = CInt(x)
  15.     Me.txtAddRunnerEventid.SetFocus
  16.     Me.txtAddRunnerEventid.Text = y
  17.  
  18.     a = Mid(s, i + 1)
  19.     b = CInt(a)
  20.     Me.txtInputRunnerid.SetFocus
  21.     txtAddRunnerRaceid = b
  22.     End If
  23.  
  24. End Sub
  25.  
I have use extra variable because I thought I had to convert the text into integer before assigning. any help would be appreciated to solve the problem.
Apr 3 '10 #1
17 9539
patjones
931 Expert 512MB
Hi zombie -

Just as a note for future reference, please use code tags when posting VBA...

Can you indicate what line the error is happening on? You can do this by setting a breakpoint in the code and then stepping through it line by line using the F8 button, until the error gets triggered.

Looking at your code, I see one possibility for the error, but I'd like to confirm first that it's where Access is stopping before I point it out.

Pat
Apr 3 '10 #2
missinglinq
3,532 Expert 2GB
What exactly is the purporse of the "|" in your code?

Welcome to Bytes!

Linq ;0)>
Apr 3 '10 #3
RuralGuy
375 Expert 256MB
Here is a simpler way to do what you are doing. http://www.baldyweb.com/OpenArgs.htm
Apr 4 '10 #4
@zepphead80
Thank you for your response. I am new to VBA and am not sure what exactly you mean by tags.

I get error when I try to assign values into text fields "Me.txtAddRunnerEventid.Text" and "txtAddRunnerRaceid". The text fields are part of an associative table (event-race-runner table). What I am trying to do is assign the value that I extract from a prior form and insert into the event-race-runner associative table - thus inserting eventid and raceid. For some reason, access is not allowing me to input that values as it gives me error 2448: You can't assign value to this object. To get around the problem, I tried to use VBA instead of macro from in the previous form save button. But even in that I get error message saying that I am an error in the INSERT STATEMENT. The following is the SQL INSERT command I used:

CurrentDb.Execute "INSERT INTO event-race-runner (eventid, raceid, runnerid) VALUES (txtAddRunnerEventid, txtAddRunnerRaceid, txtAddRunnerRaceid)"

The above SQL command also includes a runnerid that is autogenerated.
Apr 4 '10 #5
@RuralGuy
Thank you. This is definitely lot easier and I am using this instead of my old VBA code.
Apr 4 '10 #6
@missinglinq
I use it to separate the arguments that I am passing from one form to another.
Apr 4 '10 #7
RuralGuy
375 Expert 256MB
You're welcome. Glad we could help.
Apr 4 '10 #8
Hi RuralGuy,

I am still unable to solve the error message and I could really use some help. Here is additional explanation about my error:

I get error when I try to assign values into text fields "Me.txtAddRunnerEventid.Text" and "txtAddRunnerRaceid". The text fields are part of an associative table (event-race-runner table). What I am trying to do is assign the value that I extract from a prior form and insert into the event-race-runner associative table - thus inserting eventid and raceid. For some reason, access is not allowing me to input that values as it gives me error 2448: You can't assign value to this object. To get around the problem, I tried to use VBA instead of macro from in the previous form save button. But even in that I get error message saying that I am an error in the INSERT STATEMENT. The following is the SQL INSERT command I used:

CurrentDb.Execute "INSERT INTO event-race-runner (eventid, raceid, runnerid) VALUES (txtAddRunnerEventid, txtAddRunnerRaceid, txtAddRunnerRaceid)"

The above SQL command also includes a runnerid that is autogenerated.
Apr 4 '10 #9
RuralGuy
375 Expert 256MB
To start with, controls have both a .Text property as well as a .Value property. The control needs to have the focus if you use the .Text property but not if you use the .Value property (the default). I mostly use the .Value property and Me.ControlName.Value and Me.ControlName both will use the .Value property.
Apr 4 '10 #10
RuralGuy
375 Expert 256MB
Is event-race-runner a TABLE or a QUERY?
Apr 4 '10 #11
event-race-runner is a table.
Apr 4 '10 #12
RuralGuy
375 Expert 256MB
Are those values the same values passed in the OpenArgs argument and is the event-race-runner table the RecordSource of the 2nd form?
Apr 4 '10 #13
@RuralGuy
Yes, the values passed on from OpenArgs should give me eventid and raceid. However, the runnerid is autogenerated value coming from runner table. What I am trying to do here is input all three ID values into event-race-runner table. To do so, I wanted to use values in text boxes and insert into the event runner table. I tried using the following SQL command but I get an error message saying I have incorrect INSERT statement.

CurrentDb.Execute "INSERT INTO event-race-runner (eventid, raceid, runnerid) VALUES (txtAddRunnerEventid, txtAddRunnerRaceid, txtAddRunnerRaceid)"
Apr 4 '10 #14
RuralGuy
375 Expert 256MB
What is the RecordSource of your 2nd Form?
Apr 4 '10 #15
@RuralGuy
I am not exactly sure what you mean by RecordSource. However I selected the form that I am trying to input all data and copied and pasted the RecordSource. Hopefully this is what you are looking for. If not, please let me know. Sorry, but I a newbie to ms access and vba. Thanks for your help.

here is the RecordSource:

SELECT runner.runnerid, runner.firstname, runner.lastname, runner.streetaddress, runner.city, runner.state, runner.zipcode, runner.email, runner.phone, runner.dateofbirth, runner.age AS Expr1, runner.gender, runner.shirtsize, [event-race-runner].eventid, [event-race-runner].raceid, event.eventname, race.racename, [event-race-runner].runnerid AS [runnerid_event-race-runner] FROM runner INNER JOIN (race INNER JOIN (event INNER JOIN [event-race-runner] ON event.eventid=[event-race-runner].eventid) ON race.raceid=[event-race-runner].raceid) ON runner.runnerid=[event-race-runner].runnerid;
Apr 4 '10 #16
RuralGuy
375 Expert 256MB
The RecordSource you posted is a query (excellent) that joins the [runner] table with the [race] table and the [event-race-runner] table. It is possible this query is not updateable. Try opening the query by pressing the "..." button on the RecordSource line of the property sheet and see if you can change anything. If it just beeps then the query is not updateable. http://allenbrowne.com/ser-61.html
Apr 4 '10 #17
patjones
931 Expert 512MB
Hi -

Rural Guy is giving some great insight here.

Are the text boxes that you are assigning the values to bound or unbound? For a little explanation on the difference, see read the first couple of paragraphs of the following page:

http://www.igetit.net/newsletters/Y0...undUBound.aspx

Pat
Apr 5 '10 #18

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

Similar topics

2
by: bradleyp | last post by:
Hi all, Hopefully somebody can help. In Access 2002-SP2, I receive an error from the VB Editor if I try to compile the following code (see below). The error is as follows: Compile Error:...
10
by: MLH | last post by:
Anybody know why I might be getting error #2109 during the procedure below? It does not occur on 2 desktops, but did on a laptop. The error said: "The following unexpected error occurred in Sub...
23
by: Jason | last post by:
Hi, I was wondering if any could point me to an example or give me ideas on how to dynamically create a form based on a database table? So, I would have a table designed to tell my application...
2
by: Phillip Galey | last post by:
I have an object called Place which contains only string properties and has the <Serializable()> flag before the class name declaration. I also have a collection object called Places, which is...
6
by: Jean Christophe Avard | last post by:
Hi! I'm designing an application that produces invoices. I have a combobox that is populated with the Name of every client in the database. What I would like to do is to have the combobox to...
2
by: Jim McGivney | last post by:
In asp 2.0 I am trying to insert a row using a detailsview control connected to an accessDataSource. I get the error message below. I am having trouble identifing which data field is causing the...
8
by: Bruno Alexandre | last post by:
Hi guys, I'm using a session to save an ArrayList, so I do not read Database everytime user reload the page or enter the site (the Data is consistent for all entire session time when the user is...
0
by: gunimpi | last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431 ******************************************************** VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help wanted...
8
Dököll
by: Dököll | last post by:
Hey gang! Below code allows me to search my database though all fields included on the form. Works great. Small issue, when I fetch partial phrases, if they contain an apostrophy, say, "Ferris...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: 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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...

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.