Basic Tips On Using VBA with Dynamics GP



Determining the GP User:

Dim strUser as UserInfo
Set strUser = vbaglobal.userinfoget()
Dim strUserID as string
strUserId=strUser.userid



Populating a Combo Box

There's no easy way to populate control source of a comboxbox, other than to put code in the "UserForm_Activate" event:
Here's an example of populating a simple, 1 column combo box:

me.cbMyCombi.AddItem ("item1")
me.cbMyCombo.AddItem ("item2")


Displaying a VBA User Form

formname.show


Populating a List Box

There's no easy way to populate a list box, other than to put code in the "UserForm_Activate" event:

Let's say you are populating a 3 column listbox from a ADO recordsource:

DIm intcount as integer
intCount=0

With me.listbox1

    .AddItem
    me.listbox1.list(intCount,0)=objrs("field1")
    me.listbox1.list(intCount,1)=objrs("field2")
    me.listbox1.list(intCount,2)=objrs("field3")

End with

intCount=intCount+1







Comments