function & syntax

PipSmalls

New member
Local time
Today, 23:11
Joined
Apr 11, 2002
Messages
5
Hi,
I am trying to write a function and am having diffuculties with syntax and how to go about it.

When a use clicks on a textbox, i want to set a variable which is basically the name of the box. I then want to have a public function find out if that box has any text in it.

Private Sub a0845_DblClick(Cancel As Integer)
Dim a0845 As TextBox
Dim selected As String
Dim pos As Integer

selected = "a0845"
pos = 5
if_exists

End Sub
____________________________________
Public Function if_exists()

Dim exist_booking As String

If Nz(Me.[selected], "") = "" Then
MsgBox "no data"
Else
exist_booking = Me.['selected'].Value
MsgBox "There is already a booking for " & exist_booking & " Do you wish to Delete?"
Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Patients"
DoCmd.OpenForm stDocName, , , stLinkCriteria


End If
End Function

As you will see, I am trying to get it to discover if the box is empty by replacing the actual text box with 'selected'#

Can anyone tell me what i am doing wrong or how to go about this.

Cheers
 
If IsNull(Me.MyTextbox) Then
Beep
MsgBox"There is no data"
Exit Sub
End If
exist_booking = Me.MyTextbox
MsgBox "There is already a booking for " & exist_booking & " Do you wish to Delete?"
Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Patients"
DoCmd.OpenForm stDocName, , , stLinkCriteria
 
Thanks Rich, but what i am trying to do is replace the Me.myTextbox on the fly, so it adopts the 'clicked' variable
 

Users who are viewing this thread

Back
Top Bottom