During next week

Vallan

Registered User.
Local time
Today, 15:10
Joined
Jan 16, 2008
Messages
46
Hello.

I just want to ask if it is possible to make so that the user only can make a order if the date is happening during next week?


I have made a form where the user can make an order for the next week. I want to make it impossible to make posts that dont have a date that comes during next week.


i have tried to make it in a button "onclick"

Anyone who has an easy solution?


Sorry for my bad english.

Mattias
 
can you please post you onclick event code and let us know whats not working?
 
Probably i have made the solution to complicated but thats what you do when you are a beginner.

Dont laugh about my crazy coding. :o

I have made 3 new fields in the forms query.... where i make the date to weeks.

I hope you understand. And im sure that you can use the date fiekld only to make this but im not there yet in my learningprocess.

Mattias

Code:
Private Sub Kommandoknapp32_Click()
    If [Order_nextweek] < [Nextweek] Or [Order_nextweek] > [Afternextweek] Then
        MsgBox "You plan to order food for next week?" & (Chr(13) & Chr(13)) & "The date you choosen are not during next week." & (Chr(13)) & "Choose a new date or cancel your order."
    Else
        DoCmd.Close acForm, "Foodorder_next", acSaveYes
        DoCmd.Close acForm, "1_Foodlist_nextweek_HFRM", acSaveYes
End If
End Sub
 
If your code is doing the job then you can keep it like this. An alternative approach os to get week number and using that in your argument. e.g.

If Val(Format([Order_NextWeek],"ww"))<=Val(Format([Order_NextWeek],"ww"))+1 then
MsgBox "The order is within this or next week"

Else
Msgbox "Error..!!"
End if

I have not checked the code but you will get the idea what I am trying to say. If you need then put a check that the Order date >= today's date.

Good luck
 
Also, just a side note -

This part acSaveYes has nothing to do with saving the records. It has to do with saving design changes to forms/reports. So, you should probably be using acSaveNo
 

Users who are viewing this thread

Back
Top Bottom