Record source property may be invalid lỗi gì năm 2024

The record source '~sq_CTrainedEmployees subform~sq_cEmployeeInfoID' specified on this form or report does not exist.

The name of the recordsource may be misspelled, the recordsource was deleted or renamed, or the recordsource exists in a different database. -

I am unsure of where it's pulling this ~sq_cTrainedEmployees subform~sq_cEmployeeInfoID string from. The recordsource for the form is not set as such yet this is the error that I get. EmployeeInfoID is also a valid field on the linked table.

This happens after adding a combobox to the form. I have quadruple verified that my row source query string is correct....

Mình nghĩ bạn đã tạo được report bảng lương của 1 tháng rồi đúng không? Để report đấy có thể in được bảng lương cho cả 12 tháng thì đơn giản thôi. Bạn thực hiện như sau [Giả sử report bảng lương bạn đã tạo có tên là rpt_BangLuong]:

1. Bạn tạo một Query đặt tên là qry_BangLuong với câu lệnh SQL như sau: SELECT * FROM LUONG01;

2. Mở rpt_BangLuong ở chế độ Design, đặt lại thuộc tính Record Souce là qry_BangLuong

3. Tạo 1 form chọn điều kiện báo cáo có tên là frm_InBangLuong, trên form này gồm có các điều khiển: - 1 Combobox hoặc 1 text box để cho người sử dụng nhập tháng cần in bảng lương [bạn nên tạo bằng combobox vừa có thể nhập từ bàn phím hoặc có thể chọn từ danh sách từ 1 đến 12]. Ở đây tôi giả sử sẽ tạo combobox có tên là cbo_Thang - 1 Command Button có tên là cmd_OK để in bảng lương và 1 Command Button cmd_Cancel để đóng form lại.

Trong sự kiện On Click của Command cmd_OK bạn đánh các lệnh sau:

Private Sub cmd_OK_Click[] On Error GoTo loi Dim st, TenBang Dim db As Database, Qr As QueryDef TenBang = "LUONG" & trim[cbo_Thang] st = "SELECT * FROM " & TenBang & ";" Set db = CurrentDb Set Qr = db.QueryDefs["qry_BangLuong"] Qr.SQL = st Qr.Close Set db = Nothing DoCmd.OpenReport "rpt_BangLuong", acViewPreview DoCmd.Maximize Exit Sub loi: Select Case Err.Number Case Else MsgBox "Lỗi: " & Err.Number & " - " & Err.Description End Select

Để tiêu đề bảng lương thể hiện đúng bảng lương đang in, VD: bạn chọn tháng 03 thì sẽ hiện là: "BẢNG THANH TOÁN LƯƠNG THÁNG 03" thì bạn làm như sau: Giả sử tiêu đề trong rpt_BangLuong bạn tạo bằng 1 label có tên là lbl_TieuDe thì ở sự kiện Report_Open bạn thêm vào lệnh sau: lbl_TieuDe.Caption = "Bảng thanh toán lương thang " & forms["frm_InBangLuong"]!cbo_Thang

Lưu ý: khi nhập tháng từ 1-9 phải thêm số 0 vào trước [01-09] để chương trình xác đinh được đúng tên bảng bạn đặt.

I'm currently working on a form in access whose Record Source is supposed to be from a Temporary Table that should be generated at Form_Load[] and deleted when the form is closed.

The way I have it working now is that the Record Source is set to another permanant table, and when the form loads, the temporary table is generated and the record source is changed. When the form is closed, the code sets the Record Source back to whatever it was originally. This works pretty well.

However, occassionally something goes wrong, and for one reason or another, the Record Source property doesn't get switched back, though the temp table is deleted so when I try to load the form, I get the error:

The record source 'TempTable' specified on this form or report does not exist

It turns out that this error occurs even before Form_Load[] is called so I can't prepare for it before hand. The only way I can think of fixing this is trying to reset it when a button on my Home form is pressed, however this isn't optimal, since I still want to be able to open it from other locations.

Is there any way to catch this error and fix it without having to go into the form properties and change the record source any time something goes wrong?

In my forms, I have a text box [or column, on the datasheet view] which many of the Access templates have; it is the 'Open' hyperlink that takes you to the details form of that record.

When I click this 'open', it does, in fact, open the correct record in the 'Details' form. However, when I close the 'Details' form, I see that this has generated an error in the parent 'List' form, in both the 'Contacts' and the 'Location'.

This error says:

The record source 'SELECT "-1" as [ID],"[Manage Filters]" as [Filter Name] FROM Filters UNION SELECT "0" as [ID], "[Clear Filter]" as [Filter...' specified on this form or report does not exist.

The name of the recordsource may be misspelled, the recordsource was deleted or renamed, or the record source exists in a different database.

In the Form or Report's Design view, display the property sheet by clicking the Properties button, and then set the RecordSource property to an existing table or query.

However, both these forms are set to particular queries, and are displaying data properly.

What's going on and how do I fix it? Thanks!

  • 2

check the code behind all of the events for all of your forms, and then check the rs property of all of the forms as well. a fast way to search through your code modules and object modules are to enter a key phrase that is in the error message. that's always helped me.

for example, get to your code window and hit Ctrl+F, and type something like "FROM filters UNION" in the search box, and search the entire project for the matches.

pick a phrase from the error message that you're sure you can match, as error messages sometimes don't return EXACT syntax of the code that is in an error state.

good luck with it!

  • 3

Pretty odd as well that you're using numbers ["-1", "0"] as names of fields. Surely "[Manage Filters]" isn't a field in Filters table. Change all those. Also rename your Filters table to something else.

'SELECT "-1" as [ID],"[Manage Filters]" as [Filter Name] FROM Filters UNION SELECT "0" as [ID], "[Clear Filter]"

  • 4

    'SELECT "-1" as [ID],"[Manage Filters]" as [Filter Name] FROM Filters UNION SELECT "0" as [ID], "[Clear Filter]"

inet,

this crazy line above was so strange looking to me that I regarded it as an access generated error message resulting from very buggy code. I didn't even bother thinking that this person named a field as -1, although that's what the error supposedly says.

Chủ Đề