Run time error 3021- no current record

后端 未结 4 1925
天命终不由人
天命终不由人 2021-01-13 01:11

I want to link the result of a query to a Textbox but I get this error: here is my code:

Dim rst As DAO.Recordset
Set rst = CurrentDb.OpenRecordset(\"SELECT         


        
4条回答
  •  抹茶落季
    2021-01-13 01:35

    Usually, I would do this. Create a new query in Access , switch to SQL View , Paste my code there and go to Design >> Run.

    SELECT XValue, YValue,Wert FROM [tb_DCM_Daten] WHERE [FzgID]=12 AND [Name]='ABC';
    

    if your query syntax is correct you should see the result otherwise error mssg will tell where you are wrong. I used to debug a much more complicated query than yours and this is the way that I've done. If there is still error, maybe you should try

    Dim sql as String
    sql = "SELECT...."
    Set rst = CurrentDb.OpenRecordset(sql)
    

    Another possible reason might be your table name. I just wonder what is your table name exactly ? if your table contains white space you should make it like this [DCM Daten].

提交回复
热议问题