Forum Discussion
KINENE_JAMIL
Apr 10, 2023Copper Contributor
SEARCH DATA IN TABLE MS ACCESS USING VBA IN ACCESS FORM AND BUTTON
Hello I have a table Tb_ACCOUNTS am trying to create a form with a search button and i have written the VBA code below but am not getting any out put. what could be the challenge with my code. Tabl...
George_Hepworth
Apr 10, 2023Silver Contributor
Put a Debug.Print command in the line after you assign a value to the SQL string and before you open the recordset. Copy that SQL into a new query. What does it produce?
strsql = "Select FORACID,ACCT_NAME,SCHM_CODE,STAFF_PF From Tb_ACCOUNTS Where FORACID= " & Tx_Search_Acct.Value & ""
Debug.Print strsql
Set rst = CurrentDb.OpenRecordset(strsql)"
strsql = "Select FORACID,ACCT_NAME,SCHM_CODE,STAFF_PF From Tb_ACCOUNTS Where FORACID= " & Tx_Search_Acct.Value & ""
Debug.Print strsql
Set rst = CurrentDb.OpenRecordset(strsql)"
KINENE_JAMIL
Apr 12, 2023Copper Contributor
Thank you.
it helped me locate the error. i had missed the Tx_PFNum.Value = rst.Fields("STAFF_PF").
Now its working.