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...
arnel_gp
Apr 10, 2023Iron Contributor
change your strSQL to:
strsql = "Select FORACID,ACCT_NAME,SCHM_CODE,STAFF_PF From Tb_ACCOUNTS Where FORACID= '" & Tx_Search_Acct.Value & "'"
strsql = "Select FORACID,ACCT_NAME,SCHM_CODE,STAFF_PF From Tb_ACCOUNTS Where FORACID= '" & Tx_Search_Acct.Value & "'"
- KINENE_JAMILApr 10, 2023Copper ContributorI have changed it, but still same problem no output.
Thank you.- George_HepworthApr 10, 2023Silver ContributorPut 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)"- KINENE_JAMILApr 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.