Form - Household inventory - add new room to table? (1 Viewer)

Matthew Lamkin

Registered User.
Local time
Today, 16:12
Joined
Oct 25, 2001
Messages
21
Hello, I have just made a small form to do an identical job as the "Rooms" form that is used in the 97 wizard room inventory database.

Eventually I want to do the same function & double click on a field, bring up this form & use it to enter a new record in a table, that then displays in the original field double clicked on.

When I double click, the rooms form comes up with no data showing (blank spaces).
How do I achieve this? I see data in mine?

Thankyou.
 

Matthew Lamkin

Registered User.
Local time
Today, 16:12
Joined
Oct 25, 2001
Messages
21
After looking, is this done in the coding?

with the
DoCmd.OpenForm "Rooms", , , , , acDialog, "GotoNew"
string?

Code:
Private Sub RoomID_NotInList(NewData As String, Response As Integer)
    MsgBox "Double-click this field to add an entry to the list."
    Response = acDataErrContinue
End Sub

Private Sub RoomID_DblClick(Cancel As Integer)
On Error GoTo Err_RoomID_DblClick
    Dim lngRoomID As Long

    If IsNull(Me![RoomID]) Then
        Me![RoomID].Text = ""
    Else
        lngRoomID = Me![RoomID]
        Me![RoomID] = Null
    End If
    DoCmd.OpenForm "Rooms", , , , , acDialog, "GotoNew"
    Me![RoomID].Requery
    If lngRoomID <> 0 Then Me![RoomID] = lngRoomID

Exit_RoomID_DblClick:
    Exit Sub

Err_RoomID_DblClick:
    MsgBox Err.Description
    Resume Exit_RoomID_DblClick
End Sub
 

Mile-O

Back once again...
Local time
Today, 16:12
Joined
Dec 10, 2002
Messages
11,316
Matthew Lamkin said:
Code:
Private Sub RoomID_NotInList(NewData As String, Response As Integer)
    MsgBox "Double-click this field to add an entry to the list."
    Response = acDataErrContinue
End Sub

Private Sub RoomID_DblClick(Cancel As Integer)
On Error GoTo Err_RoomID_DblClick
    Dim lngRoomID As Long

    If IsNull(Me![RoomID]) Then
        Me![RoomID].Text = ""
    Else
        lngRoomID = Me![RoomID]
        Me![RoomID] = Null
    End If
    DoCmd.OpenForm "Rooms", , , , , acDialog, "GotoNew"
    Me![RoomID].Requery
    If lngRoomID <> 0 Then Me![RoomID] = lngRoomID

Exit_RoomID_DblClick:
    Exit Sub

Err_RoomID_DblClick:
    MsgBox Err.Description
    Resume Exit_RoomID_DblClick
End Sub

What's with the "GotoNew" argument?
 

Matthew Lamkin

Registered User.
Local time
Today, 16:12
Joined
Oct 25, 2001
Messages
21
Me not know, me from Barcolona! (apologies to anyone actually from there :) )

It's part of the database created by the access97 wizzard, try it.
Maybe this bit send it to the end of the table & gets it ready to enter new data & hence does not display any current data (which is what I want) I'm not sure.

I do not want the record add/up/down arrows to be there.

thankyou.
 

Mile-O

Back once again...
Local time
Today, 16:12
Joined
Dec 10, 2002
Messages
11,316
I only ask because it looks like a workaround when all you need to do is:

Code:
DoCmd.OpenForm "Rooms", , , , acFormAdd, acDialog
 

Matthew Lamkin

Registered User.
Local time
Today, 16:12
Joined
Oct 25, 2001
Messages
21
SJ McAbney said:
I only ask because it looks like a workaround when all you need to do is:

Code:
DoCmd.OpenForm "Rooms", , , , acFormAdd, acDialog

So thats all I would need to add into the doubleclick event?
 

Matthew Lamkin

Registered User.
Local time
Today, 16:12
Joined
Oct 25, 2001
Messages
21
WAY TO GO!

Thanks, thats much easier.

I guess the default MS stuff has a lot of error checking or something in etc.
 

Matthew Lamkin

Registered User.
Local time
Today, 16:12
Joined
Oct 25, 2001
Messages
21
Further to this.

When I double click on a field, I can get it to bring up a new form that allows me to enter data into the table.

however once I exit that form, although the data may be in the table, its not displayed in the form that called it in the first place.

how do I achieve this?

Thankyou.
 

Mile-O

Back once again...
Local time
Today, 16:12
Joined
Dec 10, 2002
Messages
11,316
You would need to requery the form or the control which displays the data.

i.e.

For form: Me.Requery
For control: My.MyControl.Requery
 

Users who are viewing this thread

Top Bottom