Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Trouble referencing a memvar
Message
De
19/09/2001 17:10:07
 
 
À
19/09/2001 17:05:04
Information générale
Forum:
Microsoft Office
Catégorie:
Access
Divers
Thread ID:
00558498
Message ID:
00558519
Vues:
15
This message has been marked as the solution to the initial question of the thread.
>I have an input form with several unbound textboxes.
>
>
text1]       York
>[text2]       Wells
>[text3]       Mike123
>[text 4 starting value text4] 1       [text 5 ending value text4]    4
>
>
>fields 4,5 are a range.
>
>For example: text1 = county, text2 = city, text3 = employee id and text4 = building number (there can be more than one building).
>
>My problem is when I store the values to memory variables and try to insert hem into the table I get errors with textbox 3. I assume it is because it contais letter and numbers. The field it is going to is a text field. I must have a istake in my INSERT INTO statement.
>
>
>
mvar1 = me!text1.value
>mvar2 = me!text2.value
>mvar3 = me!text3.value
>mvar4 = me!text4.value
>mvar5 = me!text5.value
>
>Do Until mvar4 > mvar5
> DoCmd.RunSQL ("insert into labels (county, city, employee id, building) _
> values (" & mvar1 & ", " & mvar2 & ", " & mvar3 & ", & mvar4  & ")")
> mvar4 = mvar4 + 1
> loop
>
>The result should be a table with 4 records:
>
>York, Wells, Mike123, 1
>York, Wells, Mike123, 2
>York, Wells, Mike123, 3
>York, Wells, Mike123, 4
>
>Any help would be greatly appreciated.
>
>Could it be the space in between the third field name? I think if you enclose it within brackets it should work: (didn't test)
>
>DoCmd.RunSQL ("insert into labels (county, city, [employee id], building) _
> values (" & mvar1 & ", " & mvar2 & ", " & mvar3 & ", & mvar4 & ")")
>HTH
>
>
>No that's not it. The message I get is:
>
Syntax Error (Missing Operator) Query Expression 'Mike123'
OK, I noticed something else: string values should be enclosed within single quotes:
DoCmd.RunSQL ("insert into labels (county, city, [employee id], building) _
 values ('" & mvar1 & "', '" & mvar2 & "', '" & mvar3 & "', & mvar4  & ")")
Still didn't test, but that's what sticks out :)
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform