LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Continuing problem populating userform from a previous record

I have written a programme to find a previous record in my database
(presently on 35 records but will eventually grow to about 1500
records).

This is my search program (It finds the record that I want based on my
inputing the Last Name of the person whose record I want) and it works
flawlessly each tim.

Option Explicit
Sub cbSearch()

Dim Searchvar As String
Dim i As Integer
Dim x, y As String
Dim st As String

'Sheets(1).Activate

Searchvar = InputBox("Enter the Lastname to find")
Searchvar = Trim$(Searchvar) ' removes surplus spaces


For i = 5 To 1500
x = Cells(i, 1).Value
y = Cells(i, 1).row

If Cells(i, 1).Value = Searchvar Then
MsgBox ("Found it! Its ") & Cells(i, 1).Value & (" at row
") & Str(y)
Cells(y, 1).Activate
st = Selection.Address
MsgBox st
UserForm4.Show

' GoTo Recfixed
End If

If Cells(i, 1).Value = "" Then
End If
Next
Recfixed:
End Sub


Once the program goes to "Userform4.show" I want to be able to pull
information from the record and plucg it back into the userform4.

Here is the code for the Userform4.

Private Sub UserForm_Initialize()
Dim Ts, Lu, y, i As Integer
Dim x As String
Dim st As String
Dim lastrow As Range
ActiveWorkbook.Sheets(1).Activate

st = Selection.Address
With lastrow
Set lastrow = Cells(y, 1)
' .End(xlToLeft)
End With

' Set lastrow = Range(x)
' y = Cells(i, 1).row
' textbox.Text =
Application.Selection.Cells[Application.ActiveCell.Row,
'TextBoxTagNumber].Value




Textbox1.Text = lastrow.Offset(, 9).Value
Textbox2.Text = lastrow.Offset(, 10).Value
Textbox3.Text = lastrow.Offset(, 11).Value
Textbox4.Text = lastrow.Offset(, 12).Value
Textbox5.Text = lastrow.Offset(, 13).Value
Textbox6.Text = lastrow.Offset(, 14).Value

End Sub

Theprogram generates an error message
"Run time error '1004'
Application - defined or object-defined error"

at the point "Set lastrow = Cells(y, 1)".

I have tried several different fixes but an error still occors.

Anyone got any ideas? This is driving me nuts.

Dooley007

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Open new record with selected fields from previous record Design by Sue Excel Discussion (Misc queries) 1 June 12th 09 02:24 PM
Populating fields based on previous column values MMH Excel Programming 3 May 11th 05 09:18 PM
Re-Populating Previous Answers into a User Form from the Spreadshe Tom Ogilvy Excel Programming 0 September 9th 04 09:34 PM
problem with populating a combo box on a userform JulieD Excel Programming 0 September 7th 04 03:42 PM
Need help autopopulating next new record with previous record data Harry S[_3_] Excel Programming 2 October 1st 03 10:59 PM


All times are GMT +1. The time now is 06:44 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"