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

Goto New on OpenForm

Status
Not open for further replies.

Blondie96

Programmer
Aug 12, 2004
119
US
I have a form to that requires a user name it's a combobox.
I want to be able to double click on it if the user doesn't exist to bring up the user table & enter a new record.

I took this code from the microsofts "resource scheduling" database template. In that database when I double click on the field, it goes to the "new record" position. When I dblclick on my form it brings the user form up, but the first record in the table is populating the form.

DoCmd.OpenForm "User", , , , , acDialog, "GotoNew"

on my form the user field is an unbound field, the lookup that creates the dropdown list functions correctly.
 
Does your "User" form test its OpenArgs property for "GotoNew" ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
I took this code from the microsofts "resource scheduling" database template
So, take a look here.
 
I tried inserting the following: (which also came from the ms resource scheduling)


Private Sub Form_Load()
If Me.OpenArgs = "GotoNew" And Not IsNull(Me(Unit)) Then
DoCmd.DoMenuItem acFormBar, 3, 0, , acMenuVer70
End If
End Sub

But I got the same results
 
What is the value of the AllowAdditions property of the User form ? (should be True)
You may also try this:
DoCmd.GoToRecord acDataForm, "User", acNewRec

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
with:
DoCmd.OpenForm "User", , , , , acDialog, "GotoNew"
form opens to first record,

without the openform
get "user object not open
 
Your problenm is in the User form not dealing correctly with its OpenArgs property.
BTW, what is User.Unit you test against null value ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Actually the correct code is w/user (I am working with both seperately)

the user is the pointer to the User file (selected in combo box)
 
I got the form to come up with "new record" selected,
I believe the problem was that on one form it was called user & the other userID.

Now I can't get the form to return the newly added record back to the original form. It did when I first ran the ms resource database, however it doesn't function there anymore (even if I create a new DB from the resource template).

My code is:

Private Sub UserID_DblClick(Cancel As Integer)

On Error GoTo Err_UserID_DblClick
Dim lngUserID As Long

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

Exit_UserID_DblClick:
Exit Sub

Err_UserID_DblClick:
MsgBox Err.Description
Resume Exit_UserID_DblClick
End Sub

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


If anyone can help me understand why this isn't returning the new user I'd appreciate it.

Thanks,

Tamra
 
You may try to replace this:
Me![UserID].Requery
By this:
DoEvents
Me![UserID].RowSource = Me![UserID].RowSource

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
I tried pasting that code (I just took the CRLF out of it)but I got:

Compile error:

Wrong number of arguments or invalid property assignment
 
what is the Row Source for your UserID ComboBox?

PaulF
 

row source of UserID cbo is:

SELECT User.UserID, User.User FROM User;
 
this code
Opened the form to add the new User Info:
DoCmd.OpenForm "User", , , , , acDialog, "GotoNew"

This requerys the ComboBox after the form closes to add the new user:
Me![UserID].Requery

This checks to see if a UserID value was saved prior to opening the form to enter the new User, and if so then to select that same item in the ComboBox:
If lngUserID <> 0 Then Me![UserID] = lngUserID

So, now the question is.. does the new info show up int the table named "User", if not then the data isn't getting saved when enter it into the form "User"

by the way... naming forms and tables the same is very confusing.. you should check out

PaulF
 
Yes, the new info shows up in the user table, it is just not passed back to the form that called it up.
 
got me on this one... are you sure it isn't tucked away towards the bottom of the ComboBox?

PaulF
 
Well, I hadn't looked there. In the resources db it appeared to put it selected in the cboUser field of the form. I can use it as it is, I just thought it would be better if it worked the way "it appeared" to in the template, without having to open the ComboBox again to retrieve it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top