Unbound form to update continuous form fields (1 Viewer)

Coldsteel

Registered User.
Local time
Today, 06:21
Joined
Feb 23, 2009
Messages
73
Hello,

I am trying to update a continuous form with multiple records with a unbound text box. I have tried the following on click event and I am only updating one record on the continuous form.

Here is my on click event vba:

Code:
Private Sub cmdarea_Click()

Area = txtupdate


End Sub

Any help would be appreciated , thanks
 

Coldsteel

Registered User.
Local time
Today, 06:21
Joined
Feb 23, 2009
Messages
73
Here is a copy of my database
 

Attachments

  • Database1.accdb
    884 KB · Views: 117

Galaxiom

Super Moderator
Staff member
Local time
Today, 21:21
Joined
Jan 20, 2009
Messages
12,851
Only the current record is affected with that code.
Updating multiple records is usually done with a query.

How does your form select those records? You would use the same criteria in the query to control which records are updated in the table.
 

Coldsteel

Registered User.
Local time
Today, 06:21
Joined
Feb 23, 2009
Messages
73
Thanks for the help,

The selection is made from the form Main, you click on the hosting field and it opens the continuous form (Hostveiw) with the matching hosting name , and it is that selection which I want to update
 

Coldsteel

Registered User.
Local time
Today, 06:21
Joined
Feb 23, 2009
Messages
73
I made the following update query with the following sql statement, is this the most efficient way?

UPDATE Inv SET Inv.Area = [Forms]![Hostveiw]![txtupdate]
WHERE (((Inv.Hosting)=[Forms]![Hostveiw]![Hosting]));
 

Galaxiom

Super Moderator
Staff member
Local time
Today, 21:21
Joined
Jan 20, 2009
Messages
12,851
That is basically it. However you will get prompts when you run the query with DoCmd.OpenQuery

Use the following code and that will be avoided. This code is for numeric values and will need to be modified with the proper delimiters for string or date values.

Code:
 Dim strSQL as String
strSQL = "UPDATE Inv SET Inv.Area =" & [Forms]![Hostveiw]![txtupdate]" _
       & " WHERE Inv.Hosting=" & [Forms]![Hostveiw]![Hosting]
 
CurrentDb.Execute strSQL, dbFailOnError
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 07:21
Joined
Feb 19, 2002
Messages
43,223
If you have to update multiple records this way, the table is not correctly defined. The Hosting field belongs in a higher level table.
 

Galaxiom

Super Moderator
Staff member
Local time
Today, 21:21
Joined
Jan 20, 2009
Messages
12,851
If you have to update multiple records this way, the table is not correctly defined. The Hosting field belongs in a higher level table.

That may well be the case Pat, but with due respect, you really know nothng of the poster's data structure or reason for this update so it is quite inappropriate for you to make that judgement.

I can think of valid cases where such an update could be required in a normalised structure.

Looking at another post you seem to be in a very judgemental mood today.;)
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 07:21
Joined
Feb 19, 2002
Messages
43,223
you really know nothng of the poster's data structure or reason for this update so it is quite inappropriate for you to make that judgement
And your statement isn't judgemental? Did you look at the database?
 

Galaxiom

Super Moderator
Staff member
Local time
Today, 21:21
Joined
Jan 20, 2009
Messages
12,851
And your statement isn't judgemental? Did you look at the database?

Yes I have had a look at the database sample provided. There is not enough information there to determine the nature of relationships in any real data.

By your judgement I expect you have assumed that Hosting and Area are directly related but this cannot be presumed.

My comment stands.

So you are now being judgemental about my judgment of your judgmentalism?;)
 

Users who are viewing this thread

Top Bottom