I need to use a variable value as a table field name. But when I ran the code, it gave me error and didn't use variable value but used the variable as the field name. I defined the following Sub and in my main Sub I call this Sub to input variable D, then the updating query will update the field where field name is matched with the variable D value.
Please help me Thx.
Code:
Public Sub HC(D As String) Dim db As DAO.Database Dim strSQL As String Dim str1 As String strSQL = "UPDATE [HC Table] INNER JOIN [Previous Day Balances] " _ & " ON ([HC Table].Loan = [Previous Day Balances].loannum) " _ & " AND ([HC Table].Seq = [Previous Day Balances].seq) " _ & " AND ([HC Table].[Claim Type] = [Previous Day Balances].[Claim Type]) " _ & " SET [HC Table].D = [Previous Day Balances].[net_claim_balance] " _ & " WHERE ((([Previous Day Balances].net_claim_balance)<>0));" DoCmd.RunSQL strSQL End Sub
Comment