Open user form upon enter key press

ipbr21054

Well-known Member
Joined
Nov 16, 2010
Messages
5,832
Office Version
  1. 2007
Platform
  1. Windows
Hi,
On my worksheet i have in column A customers names & in column P of that row is the receipt number for that customer.
What i would like to happen is when a certain customers name in cell A is selected when i press the enter key have it open my userform called Database & if possible to then take it one step further upon opening the userform have that customers records loaded.

I can assist further with info etc should you need any other input.

Thanks
 
x = .Cells(.Rows.Count, 1).End(xlUp).Row

That's because the variable x has not been declared. With Option Explicit at the top of your module, all variables must be declared. Since it looks like it's a local variable, you should declare it within UpdateRecord_Click.
 
Upvote 0

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
Well im not sure how to do that & are you saying this could also happen with other buttons etc on the userform ?
 
Upvote 0
Dont take this as being rude but it was working fine before i used this new code so the variable was working fine then.
Dont see how it has now stopped or how to fix it

Thanks
 
Upvote 0
With Option Explicit, all variables must be declared. So you'll need to declare x like this...

Code:
[COLOR=#333333]Private Sub UpdateRecord_Click()[/COLOR]
Dim C As Range
Dim i As Integer
Dim msg As String
[COLOR=#ff0000]Dim x as Long[/COLOR]
[COLOR=#333333]If Not IsComplete(Form:=Me) Then Exit Sub
[/COLOR]'etc
'
'
End Sub

I haven't looked through the rest of your code, but if you have other variables that are not declared, you'll get the same error.
 
Last edited:
Upvote 0
Many thanks youve been a great help to make this happen.

Now sorted so have a nice day.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,184
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top