Check if a date exists in a record

Joined
Feb 18, 2013
Messages
3
Reaction score
0
I am new to this access and vba thing , but want to learn and i have a problem.I am working on a database at work and was wondering is any one can help


i have database called records and 2 fields called Date1 and Day/Night,
i have a form with a textbox called Text 2 and combo0.
Date1 and Text1 are date fields as Day/Night and combo0 are text fields
i also have a button on the form


this is a much simpler database than i have writen but it will do to explain my problem

when i enter a date into Text1 and either day or night in to combo0 i want to be able to check to see if the record already exists or not

eg date and day or date and night

the plan is if it does exist then go to that record and edit the record and if it doesnt exists go to a new record.

I have tried the findfirst and Dlooup with out sucess

i am really at the end of my tether over this.
i have attched the database so you my understand what i am on about.



If any one can help i will be so gratefull
 

Attachments

  • log picker.zip
    22.8 KB · Views: 127
Joined
Feb 18, 2013
Messages
3
Reaction score
0
A bit of a update. I have now been able to check for the date and it works.
when it finds a valid date i then ask if my combo0 = day/night in the if statment but an error comes up " TYPE MISMATCH"


Any ideas?

Dim rs As DAO.Recordset
Set rs = Me.RecordsetClone
With rs

.FindFirst "[Date1] = #" & Format(Me![Text2], "mm\/dd\/yy") & "#"
If .NoMatch Then
MsgBox "No Match"
Else

If "[Day/Night] = """ & Me![Combo0] & """" Then (this is the line i have the error in)

MsgBox "found it"
End If
Me.Bookmark = .Bookmark
End If
End With



I have even put them together but still type mismatch
.FindFirst "[Date1] = #" & Format(Me![Text2], "mm\/dd\/yy") & "#" And "[Day/Night] = """ & Me![Combo0] & """"



these two work on their own

.FindFirst "[Date1] = #" & Format(Me![Text2], "mm\/dd\/yy") & "#"
.FindFirst "[Day/Night] = """ & Me.Combo0 & """"

but i just cant find a way of combining them
 

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