Finding day (1 Viewer)

dlugirapfr

Registered User.
Local time
Tomorrow, 00:01
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.
 

dlugirapfr

Registered User.
Local time
Tomorrow, 00:01
Joined
Nov 22, 2012
Messages
68
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.
 

pr2-eugin

Super Moderator
Local time
Today, 23:01
Joined
Nov 30, 2011
Messages
8,494
Make sure that the code is inside a Common module and not located inside a Form Module..
 

dlugirapfr

Registered User.
Local time
Tomorrow, 00:01
Joined
Nov 22, 2012
Messages
68
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 :/
 

pr2-eugin

Super Moderator
Local time
Today, 23:01
Joined
Nov 30, 2011
Messages
8,494
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..

 

Attachments

  • Form_Mod.png
    Form_Mod.png
    6.1 KB · Views: 133

pr2-eugin

Super Moderator
Local time
Today, 23:01
Joined
Nov 30, 2011
Messages
8,494
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..
 

dlugirapfr

Registered User.
Local time
Tomorrow, 00:01
Joined
Nov 22, 2012
Messages
68
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:
 

dlugirapfr

Registered User.
Local time
Tomorrow, 00:01
Joined
Nov 22, 2012
Messages
68
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"
 

pr2-eugin

Super Moderator
Local time
Today, 23:01
Joined
Nov 30, 2011
Messages
8,494
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?
 

dlugirapfr

Registered User.
Local time
Tomorrow, 00:01
Joined
Nov 22, 2012
Messages
68
From today result must be 12/12/2012. (funny date ;) ) This function must show date of Wednesday from today minimum 14 days later.
 

spikepl

Eledittingent Beliped
Local time
Tomorrow, 00:01
Joined
Nov 3, 2010
Messages
6,142
You did not name your module as
WyznaczSrode, did you?
 

dlugirapfr

Registered User.
Local time
Tomorrow, 00:01
Joined
Nov 22, 2012
Messages
68
: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

Top Bottom