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 Mike Lewis 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
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.
 
What value do you have in your variable [tt]strMonth [/tt] when the error happens?

This code works for me, as long as you have a [blue]valid Month[/blue] assigned to [tt]strMonth[/tt]

Code:
Dim strMonth As String
Dim getIntMonthFromString As Integer

strMonth = [blue]"August"[/blue]

getIntMonthFromString = Month(" 1 / " & strMonth & " / 2013")

MsgBox getIntMonthFromString

Pozdrowionka... :)

---- Andy

There is a great need for a sarcasm font.
 
Hi Andy!
I am very happy with your response.
The database I am trying to use was downloaded from the OXICOOTIN colleague's link ...
I tried to get to know her possibilities without any changes.
The first thing I see in your answer is the difference in code.
In the code that I have, there is no line "Dim getIntMonthFromString As Integer".
Could you share the code that you use?
Maybe I could use your help in another language (pl?) ...
Pozdróweczko.
 
The difference in code is because you have variables [tt]strMonth[/tt] and [tt]getIntMonthFromString[/tt] declared some place else, so for my example to work I declared them locally.

To check what's going on in your code, you may [blue]simply add to your code[/blue]:

Code:
...[blue]
MsgBox strMonth [/blue]
getIntMonthFromString = Month(" 1 / " & strMonth & " / 2013")
...
and then run it and see what you have in the message box.

PS. We could switch to another language (PL), but this is an English forum and other people may benefit from this tread as well.

Cześć [wavey3]



---- Andy

There is a great need for a sarcasm font.
 
Thank you.
I put in the line "MsgBox strMonth" according to your suggestion and now after clicking on any subFormMonth I see msgBox with the name of the month for the cloned subFormMonth. When I click OK the message "ERRR 13" returns again
...?
Pozdróweczko.
 
OK, try this.
Start new Access, one simple Form, one command button on the Form.

This code works for me:
Code:
Option Explicit

Private Sub Command1_Click()
Dim strMonth As String
Dim getIntMonthFromString As Integer

strMonth = "August"
getIntMonthFromString = Month(" 1 / " & strMonth & " / 2013")
MsgBox getIntMonthFromString

End Sub

The same code with [red]this change[/red] does not work, I get an error 12:
Code:
Option Explicit

Private Sub Command1_Click()
Dim strMonth As String
Dim getIntMonthFromString As Integer

strMonth = "[red]Sierpien[/red]"
getIntMonthFromString = Month(" 1 / " & strMonth & " / 2013")
MsgBox getIntMonthFromString

End Sub



---- Andy

There is a great need for a sarcasm font.
 
No success ...
In both cases, the message "A problem occurred during communication between Microsoft Access and the OLE server or ActiweX control."
What References are needed?
Best Regards.
 
So you stared totally new Access, placed a command button on a Form, placed the code I gave you, and that is where you get the new error: "A problem occurred..." ?



---- Andy

There is a great need for a sarcasm font.
 
Yes.
I'm sorry ... I have no idea.
Which references are chosen for you?
mine is:
Visual Basic For Applications
Microsoft Access 14.0Object Library
Ole Automation
Microsoft Office 14.0 Access database engine Object Library
Microsoft Office 14.0 Object Library
Microsoft outlook 14.0 Object Library

Best Regards.
 
Interesting, and Interesujace...

What about if you just do this in the Click Event for your command button:

Code:
Dim getIntMonthFromString As Integer

getIntMonthFromString = Month(Date())
MsgBox getIntMonthFromString

Any errors?
What do you have in the message box?


---- Andy

There is a great need for a sarcasm font.
 
Something wrong with my system ...

I started the virtual machine and got the result "8".
That's it?

Best Regards.
 
No errors, right?
Message box with 8 is OK, it is the 8th months of the year, August, or in your case - Sierpien.

Just occurred to me - I do dates in US format: Month/Day/Year
Your date format may be different, European style...
Try different date formats to see which one will work on your system:

Code:
Dim getIntMonthFromString As Integer

getIntMonthFromString = Month("[red]18/8/2018[/red]")
MsgBox getIntMonthFromString 

getIntMonthFromString = Month("[red]8/18/2018[/red]")
MsgBox getIntMonthFromString


---- Andy

There is a great need for a sarcasm font.
 
The system is smart ...
In both cases, "8".

Best Regards.
 
OK, we are getting somewhere.... :)

Try to [blue]add this:[/blue]
Code:
Dim getIntMonthFromString As Integer

getIntMonthFromString = Month("18/8/2018")
MsgBox getIntMonthFromString
[blue]
MsgBox MonthName(getIntMonthFromString)
[/blue]

What do you get in the second message box?


---- Andy

There is a great need for a sarcasm font.
 
second message box = August (sierpień) [pipe]
 
OK, what about this:

Code:
Dim getIntMonthFromString As Integer
Dim strMonth As String

strMonth = "Luty"

getIntMonthFromString = Month("18 " & strMonth & " 2018")
MsgBox getIntMonthFromString

MsgBox MonthName(getIntMonthFromString)

Do you get 2 in first box, and Luty in the second message box?


---- Andy

There is a great need for a sarcasm font.
 
Do you get 2 in first box? =YES
Do you get Luty? =YES
Best Regards.

 
But I would guess if you change "Luty" and put "Sierpień" instead, you will crash with the original error..
Try it, let me know.


---- Andy

There is a great need for a sarcasm font.
 
I opened the database, changed the word Luty to Sierpień, saved, debugged and clicked once = 8, again = Sierpień ...
No Error.
 
You may now try to change your original code in your application:
Code:
getIntMonthFromString = Month(" 1 / " & strMonth & " / 2013")

to (eliminate / )
Code:
getIntMonthFromString = Month("1 " & strMonth & " 2013")

---- Andy

There is a great need for a sarcasm font.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top