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!

syntax error 1

Status
Not open for further replies.

CHTHOMAS

Programmer
Jun 16, 1999
106
0
0
AE
Visit site
I have the following code attached to a button on a form. Am getting a syntax error. Can anyone help me? Am very new to VB.

Private Sub cmdExit_Click()
ThisDrawing.Input_mas_tag (txtMas_tag.Value,txtMas_tag1.Value )
End Sub

Regards,

Charley
 
Is that a function call?

You may not need the brackets around the parameters

Transcend
[gorgeous]
 
Sorry to trouble you again. Now Am getting the following error

Run time error 3061: too few parameters expected2.

Here is a sample of the code. I don't understand why the values are not getting passed into the function.


Public Sub Input_mas_tag(tmas_tag As String, tmas_tag1 As String)
Dim acad_txt_ent As Object
Dim rec As Recordset
Dim st As String
Dim col As Integer, row As Integer, count As Integer
Dim main_values As Variant

UserForm1.Hide
st = "select * from TAG_MASTER where ITAG = tmas_tag And STG1 = tmas_tag1"
' st = "select * from TAG_MASTER where ITAG = " + Chr(34) + tmas_tag + Chr(34) And STG1 = " + Chr(34) + tmas_tag1 + Chr(34)"
' st = "select * from TAG_MASTER where ITAG = " + Chr(34) + tmas_tag + Chr(34) + ";"
Set rec = db.OpenRecordset(st)
If rec.BOF = False Then
main_values = rec.GetRows(rec.RecordCount)
For Each acad_txt_ent In ThisDrawing.ModelSpace
If acad_txt_ent.EntityName = "AcDbText" Then
For count = 0 To UBound(main_values, 1) Step 1
If acad_txt_ent.TextString = rec.Fields(count).SourceField Then
If IsNull(main_values(count, 0)) = False Then
acad_txt_ent.TextString = main_values(count, 0)
Else
acad_txt_ent.TextString = "-"
End If
acad_txt_ent.Update
Exit For
End If
Next count
End If
Next
Else
MsgBox "no record found", vbOKOnly
End If
End Sub

 
I assume you get this error on the same line?

Try this

ThisDrawing.Input_mas_tag txtMas_tag.text,txtMas_tag1.text

Transcend
[gorgeous]
 
Sorry .. what line are you getting that error on?

Transcend
[gorgeous]
 
You are right. Am getting error on the following line.

ThisDrawing.Input_mas_tag txtMas_tag.Value,txtMas_tag1.Value

Regards,

Charley
 
Hi again,

I tried your code, but still getting the same error.

ThisDrawing.Input_mas_tag txtMas_tag.text,txtMas_tag1.text

I could see the values in debug mode when i place the cursor above the parameters.



 
And it's saying you have too few parameters??

Strange ...

Have you tried creating two variables and using those instead?

Dim strMas_tag as string
Dim strMas_tab1 as string

strMas_tag = txtMas_tag.text
strMas_tag1 = txtMas_tag1.text

ThisDrawing.Input_mas_tag strMas_tag, strMas_tag1

Although I can't see why it wouldn't be working

Transcend
[gorgeous]
 
Thanks. Let me fiddle around a little bit. Thank you sparing your valuable time.

Regards,

Charley
 
No problem at all, let me know if you're still having trouble and we'll work through it

Transcend
[gorgeous]
 
if you are calling a function and sending parameters, there are 2 ways.

1. if function has only 1 parameter, use this
functionname parameter name

in this case,
ThisDrawing.Input_mas_tag txtMas_tag.Value

if ypu have multiple parameters, use "call" before the function name and enclose the parameters in ()

try it :)

 
Sorry. Still without a solution and getting the same error message too few parameters expected2 even after trying CALL before the function name and enclosing the parameters within (). I tried

call ThisDrawing.Input_mas_tag (strMas_tag, strMas_tag1)
 
Your parameters missing look like these:

st = "select * from TAG_MASTER where ITAG = tmas_tag And STG1 = tmas_tag1"

So:

st = "select * from TAG_MASTER where ITAG = '" & tmas_tag & "' And STG1 = '" & tmas_tag1 & "'"

Remove the single quotes if the fields are not text fields, but number fields instead

To catch an error like this it helps to put an error handler right inside the proceedure. Then you will see where the error is actually occuring - I suspect on the line:
Set rec = db.OpenRecordset(st)




 
ok try this please


Private Sub cmdExit_Click()
call ThisDrawing.Input_mas_tag(txtMas_tag,txtMas_tag1)
End Sub

and please be sure of ur finction name
 
Thanks. The suggestion by CCLINT solves the problem. Now its working fine. Thanks to everyone for their help

Charley
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top