Finding day

dlugirapfr

Registered User.
Local time
Today, 06:42
Joined
Nov 22, 2012
Messages
68
Hello,

Last time i wrote the module to find wensday minimum two weeks later from today. It looks like this:
Code:
Public Function WyznaczSrode(DataWystawienia As Date) As Date
Dim a As Date
Dim c As Integer

  a = DataWystawienia + 14
  c = Weekday(a)
  
  Do While c <> 6
    a = a + 1
    c = Weekday(a)
  Loop
  WyznaczSrode = a + TimeSerial(10, 0, 0)

End Function

When i put this module in querry like this Access report error "WyznaczSrode is not defined"
Code:
Wyr1: WyznaczSrode([DataWystawienia])
Is it possible to use this module like this WyznaczSrode(Date()) ?

Thanks for answers.
 
Or Maybe you have any idea how to wrote module (and how to run it in query) that can find minimum two weeks later first wensday. Thanks for answers.
 
Make sure that the code is inside a Common module and not located inside a Form Module..
 
Maybe my question is stupid but how to check it ?
This module is not in form, this module was build as new module from in the access window (this window with query tables forms ...) It still doesn't work :/
 
Well what you need to do is go to the VBA Editor (Shortcut keys : Alt + F11), and you make sure the code is placed under any of the modules..

attachment.php
 

Attachments

  • Form_Mod.png
    Form_Mod.png
    6.1 KB · Views: 163
Well that is strange.. Hmmm.. okay, there is a small variation that I overlooked..
Code:
WyznaczSrode = a + TimeSerial(10, 0, 0)
Instead of having that, try..
Code:
WyznaczSrode = CDate(a & " " & TimeSerial(10, 0, 0))
Once you have done that, Save and Compile the code.. Then try in the immediate window if the function returns a value.. If it did it should work on your query..
 
Still this same error :(
Maybe there is another solution to find minimum two weeks later Wednsday. (this time serial is only for information that it will be 10:00:00):banghead:
 
I resolve problem, (I dont know why this module doesn't work) i put this line in query: DateAdd("d";IIf(Weekday(Date();4)=4;4;8-Weekday(Date();4));Date()+14) & " 10:00:00"
 
Okay, could you give the requirement of the function... Give an example using today's date..
If you have today's date two weeks from 23/11/2012 will be 07/12/2012, so does the result needs to be 05/12/2012 or 12/12/2012?
 
From today result must be 12/12/2012. (funny date ;) ) This function must show date of Wednesday from today minimum 14 days later.
 
You did not name your module as
WyznaczSrode, did you?
 
:banghead:Te name of module and name of public function was the same... that was main problem. Thanks for any answers. Please close the topic.
 

Users who are viewing this thread

Back
Top Bottom