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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Datasheet question

Status
Not open for further replies.

Mats

Technical User
Feb 18, 2000
83
EU
Hello,

Is there any way of setting the record source for a form in datasheet view through code. I know how to 'set' the record source, but the problem is that I want to change the recordset completely - new fields, different number of fields... Is there any way of doing this without writing code that does the whole form from scratch every time?

Any good (free) active-x controls that might handle something like this?

Thanks,
Mats
 
No.
Make another form and have several if need be.
Otherwise, yes you will be writing a database application from scratch.

DougP, MCP
dposton@universal1.com

Ask me how Bar-codes can help you be more productive.
 
Thanks,

I actually figured out a way to make it work like I want it to

Inputsub is a subform to the form calling my sub.
Fldgrup is a table with fieldnames and corresponding groupnames.

This procedure shows the rows in the selected group and hides the rest.
(there is actually a bug in it, but I havent yet figured it out, it leaves some fields showing when they should be hidden by the code...)

Dim rst As Recordset
Dim str As String
Dim i As Integer

str = "SELECT Field FROM FldGroup WHERE FldGroup.Group='" & Combo2 & "'"
Set rst = CurrentDb.OpenRecordset(str, dbOpenSnapshot)
rst.MoveFirst

i = 0
Do Until rst.EOF = True
Do Until i = InputSub.Form.Count - 1
If InputSub(i).Name = rst(0) Then
InputSub(i).ColumnHidden = False
i = i + 1
Exit Do
Else
InputSub(i).ColumnHidden = True
i = i + 1
End If
Loop
rst.MoveNext
Loop
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top