Select record on form and update table

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Please help
I have a form "Select a name" where i want to be able to double click the
name(one name on a continuous form field is called "new name") and have it
then update a completely different table("All Names") and a field called "new
name". So i can match the old names to the new names.
Probably do it the long way opening new forms and all that but surely there
is some useful code for this?

Mark
 
hi Mark,
I have a form "Select a name" where i want to be able to double click the
name(one name on a continuous form field is called "new name") and have it
then update a completely different table("All Names") and a field called "new
name". So i can match the old names to the new names.
Probably do it the long way opening new forms and all that but surely there
is some useful code for this?

On Local Error GoTo LocalError

Dim SQL As String

SQL = "UPDATE [All Names] SET [new name] = '" & _
Replace(yourValue, "'", "''") & "' " & _
"WHERE condition"

CurrentDb.Execute SQL, dbFailOnError

Exit Sub

LocalError:
MsgBox Err.Description


mfG
--> stefan <--
 
Thanks steve but this is where i get lost(sql). i'm double clicking a text
box on a seperate form that is a continous form(from a table called
'ListOfnewnames') ie. looks like this;

Newname *(field's name)

Mark
Fred
John
Brian
Leon
if i double click on Mark, in my other table which is called 'List of Names'
, I want it to update ListOfNames!Oldname

Dont i need a recordset or something. anyway the code below didnt work.need
advice please.

Private Sub NewNames_DblClick(Cancel As Integer)
On Local Error GoTo LocalError

Dim SQL As String

SQL = "UPDATE [ListOfNames] SET [Oldname] = ......
CurrentDb.Execute SQL, dbFailOnError

Exit Sub

LocalError:
MsgBox err.Description


End Sub


Stefan Hoffmann said:
hi Mark,
I have a form "Select a name" where i want to be able to double click the
name(one name on a continuous form field is called "new name") and have it
then update a completely different table("All Names") and a field called "new
name". So i can match the old names to the new names.
Probably do it the long way opening new forms and all that but surely there
is some useful code for this?

On Local Error GoTo LocalError

Dim SQL As String

SQL = "UPDATE [All Names] SET [new name] = '" & _
Replace(yourValue, "'", "''") & "' " & _
"WHERE condition"

CurrentDb.Execute SQL, dbFailOnError

Exit Sub

LocalError:
MsgBox Err.Description


mfG
--> stefan <--
 
hi Mark,
Thanks steve but this is where i get lost(sql). i'm double clicking a text
box on a seperate form that is a continous form(from a table called
'ListOfnewnames') ie. looks like this;

Newname *(field's name)

Mark
Fred
John
Brian
Leon
if i double click on Mark, in my other table which is called 'List of Names'
, I want it to update ListOfNames!Oldname
Is the "other table" a real table or a continous form?

Try

Forms("OtherForm").Form![OldName] = "Value"


mfG
--> stefan <--
 
Genius


Stefan Hoffmann said:
hi Mark,
Thanks steve but this is where i get lost(sql). i'm double clicking a text
box on a seperate form that is a continous form(from a table called
'ListOfnewnames') ie. looks like this;

Newname *(field's name)

Mark
Fred
John
Brian
Leon
if i double click on Mark, in my other table which is called 'List of Names'
, I want it to update ListOfNames!Oldname
Is the "other table" a real table or a continous form?

Try

Forms("OtherForm").Form![OldName] = "Value"


mfG
--> stefan <--
 
Back
Top