|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Auto Populate question
I am considering using Access for an upcoming Inventory project. I have the database all nicely made and organized, now what I am wondering is when the database is opened, can I have a form that asks "What Room Are You Working In" ... the user enters the room name and then it auto populates a field on a form. (I have that part) BUT...can it be made that when the person tabs to the next record (new record) the Room field is still populated with their choice?
Thanks for any input. Gale Fulton |
|
#2
|
|||
|
|||
|
Hi Gale,
Not exactly sure this is what you are needing, but if you wanted a particular field to autopopulate with a field from the last record, you can use something like this in the On Current event of your form Dim intNewRecord As Integer intNewRecord = Me.NewRecord If intNewRecord = True Then Room.DefaultValue = DLast("[Room]", "tblName") End If See if this is something close to what you were looking for. lwells |
|
#3
|
|||
|
|||
|
That worked nice! But now when the form opens, there is an error because the first record has that field blank. How do I make the form that pops up and asks "What Room" populate the field the first time?
Happy Holidays |
|
#4
|
|||
|
|||
|
Hi Gale,
I would trap the error which is error number 94 (Invalid Use Of Null) and use that error number to open your form with: On Error GoTo Err_Handler 'Original code goes here Exit_Handler: Exit Sub Err_Handler: If Err.Number = 94 Then DoCmd.OpenForm "What Room Form" Else Msgbox Err.Description & " " & Err.Number Resume Exit_Handler This would open your "What Room" form if it is the first record. lwells |
|
#5
|
|||
|
|||
|
You could create a form asking, then set that form as the opening form. "An interrogative splash." <-- Made that up
A simple Input box would prolly be cleaner, so you could open with a macro. |
![]() |
| Viewing: Dev Articles Community Forums > Databases > Microsoft Access Development > Auto Populate question |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|