Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Update One Record Field In Table

Status
Not open for further replies.

Kevsim

Instructor
Apr 18, 2000
385
AU
I have a Junction Table with 2 fields FixID and DocsID. The FixID key does not have duplicates but the DocsID key has.

The below statement works to Update all records for DocsID in the Table Junction (T_Junction), it changes all DocsID keys to the same number, Text 29 selects the new DocsID key number.

I only require to change one DocsID key number, I know I need a WHERE clause but can not make it work, I was trying to use a reference to the FixID key for that joining record.
There is a Text box on the form (Text188) which displays the FixID record number.

Dim strSQL As String
strSQL = "UPDATE T_Junction Set[DocsID]= " & Me.[Text29] & ";"
End Sub

I have had a look on the web but can not find the Where clause referring to a text box.
I would appreciate some assistance.
kevsim
 
Something like this ?
strSQL = "UPDATE T_Junction Set DocsID=" & Me!Text29 & " WHERE FixID=" & Me!Text188

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
First, kick your development up a notch and change Text29 to txtNewDocID or something similar. Then, I can only guess this might work. Again, the name of the control with FixID should have a descriptive name.
Code:
  Dim strSQL As String
  strSQL = "UPDATE T_Junction Set DocsID= " & _
     Me.txtNewDocID & " WHERE FixID = " & Me.txtFixID
  Currentdb.Execute strSQL, dbFailOnError

Duane
Hook'D on Access
MS Access MVP
 
PHV,
Thanks for the eply.
I had tried that but received error "Sub or Function not defined", the cursor stopped on FixID
kevsim
 
What is YOUR actual code ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
PHV,
I was using

Dim strSQL As String
strSQL = "UPDATE T_Junction Set[DocsID]= " & Me.[Text29] & ""
WHERE FixID = " & Me.Text188;"
End Sub
kevsim
 
PHV,
Code should read

Dim strSQL As String
strSQL = "UPDATE T_Junction Set[DocsID]= " & Me.[Text29] & ""
WHERE FixID = " & Me.Text188;"
DoCmd.RunSQL strSQL
End Sub

kevsim
 
So, simply use mine.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top