Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Unbound Forms and Incrementing through them

Status
Not open for further replies.

TooGoon

Technical User
Jul 8, 2003
29
US
Hi, I'm a bit new to this vba thing, so please bear with me.
I'm trying to make an unbound form for data entry only. It will gather the entered information from all the fields in the form and submit it as a new record.
I have managed to get this to work. However my method is EXTREMELY innefficient, as I simply assign each field a variable and then feed that data into the dataTable.
So what I am trying to do is set up a procedure which simply increments through each item in the form and gets the item's data and name. This would then be stored in an array, and the array would be fed into the dataTable.
So I need a method to increment through the form.
I've tried using Forms!FormName(#) to call each item, however I am running into a lot of errors with data types. Also, I seem to be getting a large number of null values from this method, which trips up any Debug.Print statement. How do I deal with that?

Is that a common way of doing this?
Are there any examples that I can look at?

Thanks
 
Must confess I don't quite understand what you're trying to achieve, but here's a faq on "looping thru the form controls" faq702-5010, which should give some information on that part of the challenge. See if you can use it, and/or post back with more specific questions, code...

Roy-Vidar
 
Thanks RoyVidar, that helped quite a bit.

Now for just one further question:
I'm using
Dim db As Database
Dim rs As Recordset
Set db = CurrentDb
Set rs = db.OpenRecordset("Q_MdrData_wLogin")

To refer to a query. It works fine. But, what I need is to see the names of each column in the query. I've tried using rs.Fields and many variations upon that, but with no luck. Everything I do either doesn't work, or brings up the value of the current record in that field.
 
That is, I would like to get the names of the query columns in string form,
eg. "ID", "Description
 
Have you tried this ?
Set rs = db.OpenRecordset("Q_MdrData_wLogin")
For i = 0 To rs.Fields.Count - 1
MsgBox "Field#" & i & ": " & rs(i).Name
Next i

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top