Changing Field Position not working

G

Guest

Please assist.

I am using the code below to change the field positions:

Function chgfldpos(strTableName As String)
Dim db As Database
Dim tblXL As TableDef

Set db = currentdb
Set tblXL = db.TableDefs(strTableName)

With tblXL
..Fields("fld1").OrdinalPosition = 0
..Fields("fld2").OrdinalPosition = 4
..Fields("fld3").OrdinalPosition = 5
End With

End Function

It's not working at all.

Please help
Thanks
 
G

Guest

I just tried that too and it worked. I created a sub to run my query then
call the function and it works. Sorry, not sure what is wrong on your end.

Sub TestFieldChg
Dim retVal As String
DoCmd.OpenQuery "Query1"
retVal = chgfldpos("Table2")
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top