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!

Checkbox True if Condition Met not working 3

Status
Not open for further replies.

RobotMush

Technical User
Aug 18, 2004
197
0
0
US
In trying to debug why I am unable to get my checkbox to register as true when the condition is met I created the following program

Private Sub FileType_AfterUpdate()
If IsNull([FileType]) Then
MsgBox "File Type Is Null"
Else
MsgBox "File Type Is " & FileType
End If
End Sub

This is supposed to check the file type field to see if it is null and display one or the other statements in the message box. However, nothing happens when I enter data and the FileType automatically generates the corresponding extension of the hyperlink I am entering.

Thank you for your help

RobotMush (Techincal User) Self Taught
 
PHV: THe controlsours of the FileType is the field name FileType. I Think that is what you are wanting to know.

In the table the FileType field is Datatype of Text.

Hope that helps.

RobotMush (Technical User) Selft Taught
 
Sorry I was not of any help... Try making ur txtbox wider if you dint, one thing you can do, is check the value of the textbox after the event is done.... if ur txtbox has a value, ur problem is not in coding.....
 
How do I check if the textbox has a value or not?
 
So, in the AfterUpdate event procedure of the hyperlink field named, say, myURL:
Private Sub myURL_AfterUpdate()
If InStr(myURL & "", ".") = 0 Then
Me!FileType = ""
Me.Parent.Form!chkHypLnk = False
Exit Sub
End If
Dim strPath As String
strPath = HyperlinkPart(Me!myURL, acAddress)
Me!FileType = Mid(strPath, 1 + InStrRev(strPath, "."))
Me.Parent.Form!chkHypLnk = True
End Sub

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thank you PHV, I've printed out the program to better analyse what it is doing and will try it out.
I'll let you know how it goes.

Thanks for all the help

RobotMush (Technical User) Self Taught
 
Hokay PHV... Here is the Program as Written, When I inserted a hyperlink in the field I got a "Run Time Error '13': Type Mismatch" message. I added the [] to the program. And Inserted another Hyperlink file into the field and got a "Run Time Error '2465':Microsoft Access Can't Find the Field "|" Referred to in your expression." Have I keyed in the program wrong?

Private Sub HypLnk_AfterUpdate()
If InStr(HypLnk - sfrm & "", ".") = 0 Then
Me!FileType = ""
Me.Parent.Form!chkHypLnk = False
Exit Sub
End If
Dim strPath As String
strPath = HyperlinkPart(Me!HypLnk - sfrm, acAddress)
Me!FileType = Mid(strPath, 1 + InStrRev(strPath, "."))
Me.Parent.Form!chkHypLnk = True
End Sub

Looking over it I'm wondering if I should change the Parent.Form to the Main Form and the Sub Form. What is your suggestion?

RobotMush (Technical User) Self Taught
 
Private Sub HypLnk_AfterUpdate()
If InStr(Me!HypLnk & "", ".") = 0 Then
Me!FileType = ""
Forms![name of mainform]!chkHypLnk = False
Exit Sub
End If
Dim strPath As String
strPath = HyperlinkPart(Me!HypLnk, acAddress)
Me!FileType = Mid(strPath, 1 + InStrRev(strPath, "."))
Forms![name of mainform]!chkHypLnk = True
End Sub

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thank you PHV
Did a cut and past of the program you provided (thank you for that) and added another hyperlink to the field. Got the following error message...

Runtime Error '3327': Field 'FileType' is Based on an Expression and can not be edited.

Would this be due to my having
"=UCase(Left(Right([tblHyperlink]![HypLnk],4),3))"
in my default value? This is to get the extension placed in the FileType field.

Thanks for being patient with all the trouble I'm presenting here.

RobotMush (Technical User) Self Taught
 
It would really help PHV if you gave him the lines where the errors come from, but I think ur problem is your trying to edit Me!FileType when its related to a read-only table or
Forms![name of mainform]!chkHypLnk

I doubt it has anything to do with the line you mentioned since it doesnt edit anything........
 
Thank you for the suggestion ItIsHardToProgram. Here is the offending line.
"Me!FileType = Mid(strPath, 1 + InStrRev(strPath, "."))"
And of course with the same error message...
"Runtime Error '3327': Field 'FileType' is Based on an Expression and can not be edited."
I don't believe the FileType Field is a read only, I have not set anything to read only. The only difference in the FileType field and other fields is that the default value is "=UCase(Left(Right([tblHyperlink]![HypLnk],4),3))" so that the extension of the hyperlink is automatically entered. If this causes the FileType to become read only I can not find where to change it back to edit form.

Thanks for your help

RobotMush (Technical User) Self Taught
 
First off, try using a textbox for your default value, and write in another textbox, using the value of the first one you defined "=UCase(Left(Right([tblHyperlink]![HypLnk],4),3))" 2nd should be refering to the first one.... and only the 2nd refering to filetype (if in a recordset)
 
Ok, I think I understand. I am to...
1)Remove the current FileType field from my form
2)create a text box field with the default value of, "=UCase(Left(Right([tblHyperlink]![HypLnk],4),3))" to replace the FileType field I removed.
3)Have the FileType field control sourse be the text box field that I created.

Do I have that right?

Thanks for your suggestion I will take care of that after I get done with my current project.

So little time, so much to do...

RobotMush (Technical User) Self Taught
 
Yes, but the textbox field that has a control source needs to be empty until u select the value from "=ucase(left(right( etc...."
If it works, it is because when the txtbox right the default value, it automaticaly defines it in filetype, and filetype is then uneditable (god knows why....)

if it still dosnt work, its another problem....
 
Ok, its another problem ItIsHardToProgram
I did the following...
1)Created a textbox called FileTypeII
2)Made the Control Source for FileType field be FileTypeII
3)Added Hyperlink
4) Got following error...
"Runtime Error '2448': You Can't Assign a Value to this Object"
5)Put Fist through Screen
Ok, so I didnt' do number 5 but it is comeing to that.
I know I have done it once before but can not locate the Database that had it. It was set up as follows
1)From the ChkBox in Form use Variable and Call Function (or it might have been sub)that is in Sub-Form
2)Function (or sub) in Sub-Form Checks Field for Relivant data
3)If Data is Relivant Variable is set to True
4)Return Variable to Program running in Form
5)Mark Check Box As True.
I think I will try this and get back with y'all for any problems I am having

Thanks for your help and the brain drain

RobotMush (Technical User) Self Taught
 
Get rid of the ControlSource and DefaultValue properties of the FileType control.
In addition to the HypLnk_AfterUpdate code I gave you, add the following code to the Current event procedure of the subform:
Call HypLnk_AfterUpdate()

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Ok, PHV, I was going to say that I needed the default value to keep the extensions automatically posting, but I guess I can get that done in the program. Will let you know how it goes.

Thanks for your help

RobotMush (Technical User) Self Taught
 
Ok, printed out the code and your last post and modified the programs. Closed and saved the form and subform and when I opened them I got...
"Run-Time Error '2448': You Can't Assign a Value to this Object". The offending line of the program is...
"Forms![HypLnk-frm]![chkHypLnk] = False"

I'm just glad I got an error message, at least I know the program is running. Now just need to figure out why it is crashing.

Thank you for all your help

RobotMush (Technical User) Self Taught
 
What is the ControlSource of chkHypLnk ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
The ControlSource of chkHypLnk is chkHypLnk in the Client Table. Should this be to a query of the table?

RobotMush (Technical User) Self Taught
 
The offending line of the program is...
"Forms![HypLnk-frm]![chkHypLnk] = False"

In which procedure ? (I guess the subform's Current event)

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top