use of me

G

Guest

I have a form with nested subforms. In the main form, I need to create new
records which I then give values to in the subforms. The main form is bound
to table dailylogs. The primary key for the dailylogs table is a date field
called TDATE. When the user clicks on the button to create a new log, I want
access to check if there is already one there. If so, I want the screen to
display that record.

Access is not recognizing my field name to refer to the date control on the
form. I can display the fields in the immediate window, but in the code, I
get the message "Error 3070 (The microsoft Jet database engine does not
recognize 'myfield' as a valid field name or expression. I have tried
numerous ways to reference this field, (forms!dailylog!tdate,
forms!dailylog.form!tdate,me.tdate, me!tdate,etc.) but it doesn't seem to
recognize any of them. If I type ?me!tdate (or whatever format I am trying)
in the immediate window, it shows me the value. What is really strange is
that it recognizes it in the DLOOKUP

Here is my code:

' first check if the day already has been created
If IsNull(DLookup("[TDATE]", "TBLDAILYLOGS", "TDATE=#" &
Form_DailyLog!tdate & "#")) Then <==== IT WORKS HERE
' create the record in the dailylogs table
Recordset.AddNew
tdate = Date
' create a record for each employee for this day
createrecords (tdate)
Else
Recordset.findfirst "tdate = me!tdate" <=== GIVES ERROR HERE
End If
 
G

GeoffG

I think you've got the quote in the wrong place. Try:

Recordset.FindFirst "tdate = " & Me!tDate

If I were doing this, I'd probably use code similar to that created by the
Find-Record wizard, which uses the RecordsetClone method and bookmarks. I
have an aversion to domain aggregate functions!

Regards
Geoff
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top