开发者

Autofill parts description via parts number text box

Sorry i don't have any code written because i have never written vba in access before. what i need to do is have a combobox autofill on my form to save a bit of time i have a database that has all our parts that includes [parts number] [parts description] [std lbs] [std lbs/hr] a few other perameters i'm just curious as to what the code would look like and where i would put it. i have a good feel for oop wor开发者_开发技巧kflow if you can provide me some sample code or a good resource i'll more than likely be able to pick up from there.

thanks /// matthew


Use the Part Number textbox's AfterUpdate Event. Your code should look like this:

Private Sub txtPartsNumber_AfterUpdate()
    If IsNull(Me.txtPartsNumber) = False Then
        Me.txtPartsDescription = Nz(DLookup("[Parts Description]", "tblParts", "[Parts Number] = '" & Me.txtPartsNumbers & "'"), "")
    End If
End Sub

Couple things I want to note. I recommend you name your fields without spaces or symbols and preferably without plurals. If I were setting up this table it would look something like this:

tblpart
--partno
--partdesc
--stdlbs
--stdlbshr

You could possibly leave off the "tbl" and just name the table 'part' since Hungarian notation has lost favor with many of today's programmers.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜