Warn about conflicting entries and offer choice to edit conflicting entry or current

Forgot about that. Move the entire function to the form.

It's just as well we use nicnames on here or you would probably find me and kill me
I don't want to make your wife a widow... yet :D
 
Not sure what you mean. Do you mean make it the before update?

The wife would probably thank you by the way;)
 
Cut and paste it anywhere on your form, in a row of it's own.

I'll give the wife enough notice to prep for the Insurance claims and Will. ;)
 
I'm completely lost. The form doesn't have rows? It's a data entry popup
 
Ok. Done that. I'm still getting a compile error on
Code:
 strTrainer = "[Trainer_Name] = '" & Me.Trainer_Name & "'"
and it has allowed me to double book a trainer.

I may have to consider reverting to something like graph paper and coloured pens:banghead:

Only kidding. I've just learned how to link a function to a form...I think

That has to be useful
 
Ok. Done that. I'm still getting a compile error on
Code:
 strTrainer = "[Trainer_Name] = '" & Me.Trainer_Name & "'"
and it has allowed me to double book a trainer.
If it errors why do you think it will stop you from double booking?

Trainer_Name has to be the name of the textbox bound to the trainer field or the name of the field itself. Start typing Me. and pick the correct name from the drop down list. Or look in the Property Sheet for the exact or look in the Expression Builder. I would expect you to know the correct name of your field.
 
Ok the field is actualy listed as cmb_Trainer_Name and the text label is Trainer_Name_Label.

I tried typing me. and waiting for it to prompt me with a list but it didn't it just waited for my input. I tried changing the code to
Code:
   strTrainer = "[cmb_Trainer_Name] = '" & Me.Cmb_Trainer_Name & "'"
and also
Code:
   strTrainer = "[Trainer_Name] = '" & Me.Cmb_Trainer_Name & "'"
but both result in Compile Error-Invalid use of Me Keyword
 
Sorry meant to post a screenshot of the field
 

Attachments

  • Picture4.jpg
    Picture4.jpg
    102.9 KB · Views: 79
You still haven't pasted the code into the right place.
 
In the VBA window I double clicked the form 'Resourcing' which then showed all the code attached to the resourcing form. I pated the function as the last entry
 

Attachments

  • Picture5.jpg
    Picture5.jpg
    98.3 KB · Views: 72
The code is attached to the form resourcing. I might have to go offline for an hour but will be back
 
1. Delete the mdlDuplicatesCheck module
2. Change the strDates code line in the form to this:
Code:
    strDates = " AND [Start_Date] BETWEEN " & Format(Me.Start_Date, "\#mm\/dd\/yyyy\#") & " AND " & _
                                              Format(Me.End_Date, "\#mm\/dd\/yyyy\#")
3. Debug > Compile, then test.
 
It works, it works, it works.

I would dance around the room but I'm shattered. What's better every combination of AM, PM and all day seems to work. I thought I had more code to do. I'm delighted.

Thank you for your time and patience beyond what is reasonable to expect.

Obviously I now have to go on and build some queries etc and I'm sure I'll have more questions but you will be totally forgiven for never speaking to me again.

At least you will be if you answer one last question....

Where is a good place to start learning VBA? I sort of learned SQL by reverse engineering the code created automatically when I created queries but I still can't seem to cope with even basic VBA. Given my stubborn determination to get access to bend to my will (even when it isn't supposed to do the thing I need) I need to get at least a basic understanding.

Once again thanks s much.

Guinness
 
I would dance around the room but I'm shattered.
Go on, give the wife a treat. Do the victory dance! ;)

You realise though that the form that opens up if you choose to edit the clashing record doesn't filter to that record? That's because you're using a subform.

Where is a good place to start learning VBA? I sort of learned SQL by reverse engineering the code created automatically when I created queries but I still can't seem to cope with even basic VBA. Given my stubborn determination to get access to bend to my will (even when it isn't supposed to do the thing I need) I need to get at least a basic understanding.
I'm self taught but I hear that functionX is a good site for learning Access and VBA.
 
Go on, give the wife a treat. Do the victory dance! ;)

She'd kill me for making too much noise and 'playing with that stupid database'

You realise though that the form that opens up if you choose to edit the clashing record doesn't filter to that record? That's because you're using a subform.

I was just wondering about that. If I opened it as a form I could use Do.Cmd to filter on the trainer_Name and even the Start_Date couldn't I?

I'm self taught but I hear that functionX is a good site for learning Access and VBA.

I'll look in to functionx. I can write some very basic instruction as you may have seen in the sample I sent but I don't understand what all the Dim's are etc

Thanks again
Guinness
 
I suppose those are the wife's words!

strCondition already holds the criteria you need to use. So :
1. DoCmd.OpenForm is opening the form.
2. The parameter where strCondition is filters the form and not the subform

Once you understand the basics everything else will fall into place. I've seen many cases of people who want to do fancy things with VBA (like make a form move etc) but yet they don't even understand the basics.
 
Hi vbaInet

Was thinking about your last comment. The form 'Edit_Hours is a main form not a subform (although I have used it as a subform elsewhere) so I should be able to filter it.

I tried
Code:
DoCmd.OpenForm "Edit Hours", , , "Trainer_Name =" & Cmb_Trainer_Name.Value
But it tells me that I am missing an operator.

My plan was to filter by both Trainer_Name and Start_Date without bothering you but this has me slightly flummoxed.

Am I kidding myself?
 

Users who are viewing this thread

Back
Top Bottom