Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Attendance Control Public v5xx

Status
Not open for further replies.

masa1

Technical User
Aug 1, 2018
15
0
0
PL
Hello.
I am very interested in trying the database published in this thread702-1741110 .
(This thread has been Closed.)
When I'm try to work on the frm_YearCalendar form, occurs error
"Run-Time error 13", when I click debug the line "getIntMonthFromString = Month (" 1 / "& strMonth &" / 2013 "is highlighted. Can I ask for help.
In previous threads I have not found a solution to this problem ...
I am not a programmer but I would like to apply this solution very much.
Best regards.
 
I wrote this code. When I wrote it I was thinking a US format. MM/DD/YYYY. I did not account for European format DD/MM/YYYY. That tends to be the biggest issue.
 
Hey.
Great respect for you and the work you have done.
I was interested in a published example that meets my expectations.
I would like to use it.
Can you give me some tips to solve this problem?
Personally, I'm not a programmer, but I'm patient ...
Thank you for every valuable remark on your part!
Best regards.
 
You may now try to change your original code in your application:
..........

to (eliminate / )
...........

No improvement.
The same error 13
Best Regards.
 
Yes MayP, the data format is the issue.
What bothers me is, if you use Luty (which is February) in this line of code:

Code:
strMonth = "Luty"
getIntMonthFromString = Month("18 " & strMonth & " 2018")

The date becomes [tt]"18 Luty 2018"[/tt] and - as masa1 stated above - it works OK. Code returns 2, which is correct.
But the original code still errors at:
[tt]getIntMonthFromString = Month("1 " & strMonth & " 2013")[/tt]
But that's the same code [banghead]


---- Andy

There is a great need for a sarcasm font.
 
In the Year View calendar, I set the label of the 12 subform instances
Code:
  sFrmJan.LblMonth.Caption = "January"
    sFrmFeb.LblMonth.Caption = "February"
    sFrmMar.LblMonth.Caption = "March"
    sFrmApr.LblMonth.Caption = "April"
    sFrmMay.LblMonth.Caption = "May"
    sFrmJun.LblMonth.Caption = "June"
    sFrmJul.LblMonth.Caption = "July"
    sFrmAug.LblMonth.Caption = "August"
    sFrmSep.LblMonth.Caption = "September"
    sFrmOct.LblMonth.Caption = "October"
    sFrmNov.LblMonth.Caption = "November"
    sFrmDec.LblMonth.Caption = "December"

You would need to change the names to the correct language

When you click on a control in the calendar it figures out which instance month subform by its label.

So you pass the label value to the function. If you click in the third subform it passes the label value of March.

Code:
Public Function getIntMonthFromString(strMonth As String) As Integer
'Assume Jan, Feb..Dec
    On Error GoTo errlbl
    getIntMonthFromString = Month("1/" & strMonth & "/2013")
    Exit Function
errlbl:
    MsgBox Err.Number & " " & Err.Description & vbCrLf & " Month Passed: " & strMonth
End Function

So this function simply makes the string 1/March/2013 and returns the value of 3.
If this does not work in your region, then roll your own function for your language
Code:
Public Function getIntMonthFromString(strMonth As String) As Integer
'Assume. Jan, Feb.De
    On Error GoTo errlbl
   Dim MonthVal as integer
   select Case  strMonth
       Case “YourFirstMonthNameHere”
           monthVal = 1
       Case “YourSencondMonthNameHere”
          monthVal = 2
       …
       Case “Your 12th Month Name Here”
           Month Val = 12
     end select
     getIntMonthFromString = MonthVal
    Exit Function
errlbl:
    MsgBox Err.Number & " " & Err.Description & vbCrLf & " Month Passed: " & strMonth
End Function
 
Hey!
My colleague "Andrzejek" thank you very much for your time, willingness to help and patience.
Thanks to you, I learned and learned something. [bow]
Mr. "MajP", you have solved the problem, YOUR database is running on my computer without any errors.
THANK YOU and once again RESPECT! [tiphat]


According to your suggestion, I changed the names of months to the right language and that was enough.


I hope that from what we have saved here, someone will benefit.

I will test and try to modify this database for my needs, I hope to give me help again if I ask ...?

Best regards.

andrzej
 
I am glad you got it working.
MayP's code is always pretty solid :)

If you have any more questions, come back to Tech-Tips. There are a lot of knowledgeable and helpful people here ready to answer questions.


---- Andy

There is a great need for a sarcasm font.
 
Hello!
I'm sorry but I came across another problem I can not deal with ...

I want to add a new employee, open the form frm_UpdateEmpInfo, choose Supervisor, then enter Date Of Hire, First Name and Last Name and click Add.
The new employee is added both in the form and in the tbluEmployees table.
Then I want to add an employee to enter the BoughtYear;

in frm_UpdateEmpInfo I click "VAC", frm_UpdateEmpInfoBoughtVac opens, but the EmployeeID field is empty (!), enter the date, check the box and open tbluBoughtVacation.

The fields BVacID, BoughtYear and BoughtVac are filled out while the field EmploeeID is empty (!)
Consequently, there is no information requested in the "Accrual Profile:" field in frm_YearCalendar
Can I ask for help? [ponder]
 
This question is not really related to your original issue, so I would start a new thread (and delete this post).

Welcome back, Andrzej [wavey3]


---- Andy

There is a great need for a sarcasm font.
 
My work was mainly on the calendar control and year form. Oxicottin did the work on the other forms and reports.
When he opens the form to edit/add an employees bought vacation he opens to that employee. The problem is there is nothing to set the employee id for new records. One solution is to set the default value of the text box txtEmployeeID.

Code:
Private Sub cmdBoughtVac_Click()
    Dim stLinkCriteria As String
    stLinkCriteria = "[EmployeeID]=" & Me![txtEmployeeID]
    DoCmd.OpenForm "frm_UpdateEmpInfoBoughtVac", , , stLinkCriteria
    'add below line of code
    Forms("frm_UpdateEmpInfoBoughtVac").txtEmployeeID.DefaultValue = Me.EmployeeID
End Sub
 
OK, I accept your reasoning, although I thought it would be better to keep threads related to this tool in one place, as it was before ...
Regards.

MajP thank you for the tips, at first I thought it was more refined.
I will try to squeeze something out of it ...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top