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

auto populating fields

Status
Not open for further replies.

twoeagles

MIS
Oct 23, 2003
1
US
I have a database (such as a calendar) & want the month & days to automatically populate table & have things such as shift 1, 2, 3, automatically appear on appropriate dates. Since this is very repetative & maybe only times/names (workers) change I could either make a pulldown/combobox & pick names (or just type them in). Any suggestions on how to get the rest of the calendar to be fairly self-populating? Thanks
 
twoeagles

The only way I know how to do this is through coding. You have to write the raw data for each record and then allow the user to enter the required data.

I used this approach for a survey or check list program. I had to populate the questionaire or check list before the end-user could answer the questions. Your code will differ, especially if you don't use DAO, but the idea is the same. Basically, I loop through each condition and write a record with the bare minimum of required data -- question text, required or not, etc, and then let the end-user answer the questions generated. My coding it a little more complicated because I actually have two loops - one for a category and the inner loop for questions for the category. Nonetheless, the process is the same.

Private Sub fill_profile_2(intMasterID, intCall, intTech, strSQL4)

Snippet of code...

Private Sub fill_profile_2(intMasterID, intCall, intTech, strSQL4)

Dim dbs As DAO.Database, rstQuestion As DAO.Recordset, rstXRef As DAO.Recordset
Dim strQ As String
Dim strSQL1 As String, strSQL2 As String, strSQL3 As String
Dim intSubID As Long, intTest As Integer, intQuestion As Long
Dim lngMstrLineNo As Long, lngSbGrpLineNo As Long

strQ = Chr$(34)
Set dbs = CurrentDb()

strSQL1 = strSQL4

strSQL3 = "select * from profile_question where profile_sbgrp_id = "

Set rstXRef = dbs.OpenRecordset(strSQL1)

rstXRef.MoveFirst

Do Until rstXRef.EOF
intSubID = rstXRef!profile_sbgrp_id
lngMstrLineNo = rstXRef!line_no

strSQL2 = strSQL3 & intSubID
Set rstQuestion = dbs.OpenRecordset(strSQL2)

intTest = rstQuestion.RecordCount

If intTest > 0 Then

rstQuestion.MoveFirst

Do Until rstQuestion.EOF

intQuestion = rstQuestion!profile_id
lngSbGrpLineNo = rstQuestion!line_no
fill_profile_3 intQuestion, intSubID, intCall, intTech, lngMstrLineNo, lngSbGrpLineNo
rstQuestion.MoveNext

Loop

End If

rstQuestion.Close
rstXRef.MoveNext
Loop

rstXRef.Close

End Sub


Private Sub fill_profile_3(intQuestion, intSubID, intCall, intTech, lngMstrLineNo, lngSbGrpLineNo)

....
If intTest = 0 Then

rstAnswer.AddNew
rstAnswer!profile_sbgrp_id = intSubID
rstAnswer!profile_id = intQuestion
rstAnswer!mstr_line_no = lngMstrLineNo
rstAnswer!sbgrp_line_no = lngSbGrpLineNo
rstAnswer!tech_id = intTech
rstAnswer!call_id = intCall
rstAnswer.Update

End If
....
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top