A varible question?

  • Thread starter Thread starter delolwai
  • Start date Start date
D

delolwai

Hi all,
I got a problem about the varible, for example :
Dim a as variant
Dim rst as variant

a = "AddNew"
Set rst = Currentdb.Openrecordset("Table");
rst.(what is the syntax of a for AddNew)???
..................
..................

(p.s: certainly I know simply rst.AddNew is ok...)

I don't know how to explain why I have to do so but I really want to
know is it any possible solution to do it.
Thx so much


Barabus
 
I've never used this in a real world application, just tested it very
briefly for this reply. With that caveat, here it is ...

Public Sub TestCallByName()

Dim strMethod As String
Dim rst As ADODB.Recordset

strMethod = "AddNew"
Set rst = New ADODB.Recordset
With rst
.ActiveConnection = CurrentProject.Connection
.CursorType = adOpenKeyset
.LockType = adLockOptimistic
.Open ("SELECT TestText FROM tblTest")

CallByName rst, strMethod, VbMethod

.Fields("TestText").Value = "A Test"
.Update
.Close
End With

End Sub


--
Brendan Reynolds (MVP)
http://brenreyn.blogspot.com

The spammers and script-kiddies have succeeded in making it impossible for
me to use a real e-mail address in public newsgroups. E-mail replies to
this post will be deleted without being read. Any e-mail claiming to be
from brenreyn at indigo dot ie that is not digitally signed by me with a
GlobalSign digital certificate is a forgery and should be deleted without
being read. Follow-up questions should in general be posted to the
newsgroup, but if you have a good reason to send me e-mail, you'll find
a useable e-mail address at the URL above.
 
Back
Top